From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- .../xmod/gregtech/common/MetaGTProxy.java | 96 ++ .../xmod/gregtech/common/Meta_GT_Proxy.java | 96 -- .../common/blocks/GregtechMetaCasingBlocks.java | 43 +- .../common/blocks/GregtechMetaCasingBlocks2.java | 44 +- .../common/blocks/GregtechMetaCasingBlocks3.java | 53 +- .../common/blocks/GregtechMetaCasingBlocks4.java | 24 +- .../common/blocks/GregtechMetaCasingBlocks5.java | 63 +- .../common/blocks/GregtechMetaCasingBlocks6.java | 20 +- .../blocks/GregtechMetaCasingBlocksAbstract.java | 20 +- .../GregtechMetaCasingBlocksPipeGearbox.java | 73 +- .../blocks/GregtechMetaItemCasingsAbstract.java | 14 +- .../blocks/GregtechMetaSpecialMachineCasings.java | 19 +- .../blocks/GregtechMetaSpecialMultiCasings.java | 45 +- .../blocks/GregtechMetaSpecialMultiCasings2.java | 22 +- .../blocks/GregtechMetaTieredCasingBlocks1.java | 30 +- .../common/blocks/fluid/GregtechFluidHandler.java | 20 +- .../textures/TexturesCentrifugeMultiblock.java | 10 +- .../blocks/textures/TexturesGrinderMultiblock.java | 4 +- .../common/blocks/textures/TexturesGtBlock.java | 32 +- .../common/blocks/textures/TexturesGtTools.java | 8 +- .../turbine/LargeTurbineTextureHandler.java | 44 +- .../xmod/gregtech/common/covers/CoverOverflow.java | 198 ++++ .../gregtech/common/covers/CoverToggleVisual.java | 184 +++ .../common/covers/GTPP_Cover_Overflow.java | 198 ---- .../common/covers/GTPP_Cover_ToggleVisual.java | 184 --- .../gregtech/common/helpers/ChargingHelper.java | 68 +- .../common/helpers/FlotationRecipeHandler.java | 8 +- .../gregtech/common/helpers/GTMethodHelper.java | 19 + .../gregtech/common/helpers/GT_MethodHelper.java | 19 - .../common/helpers/VolumetricFlaskHelper.java | 8 +- .../common/helpers/tesseract/TesseractHelper.java | 76 +- .../items/Ids_MetaGeneratedGregtechItems.java | 47 - .../gregtech/common/items/MetaCustomCoverItem.java | 14 +- .../common/items/MetaGeneratedGregtechItems.java | 288 ++--- .../common/items/MetaGeneratedGregtechTools.java | 34 +- .../common/items/MetaGeneratedItemIDs.java | 47 + .../items/behaviours/Behaviour_Choocher.java | 24 +- .../behaviours/Behaviour_Electric_Lighter.java | 52 +- .../items/behaviours/Behaviour_Prospecting_Ex.java | 62 +- .../common/items/covers/MetaItemCoverCasings.java | 4 +- .../xmod/gregtech/common/render/CapeRenderer.java | 500 ++++++++ .../xmod/gregtech/common/render/FlaskRenderer.java | 107 ++ .../gregtech/common/render/GTPP_CapeRenderer.java | 500 -------- .../gregtech/common/render/GTPP_FlaskRenderer.java | 107 -- .../common/render/GTPP_Render_MachineBlock.java | 1250 -------------------- .../common/render/MachineBlockRenderer.java | 1250 ++++++++++++++++++++ .../GT_MetaTileEntity_ElectricAutoWorkbench.java | 868 -------------- .../GT_MetaTileEntity_TesseractGenerator.java | 833 ------------- .../GT_MetaTileEntity_TesseractTerminal.java | 643 ---------- .../automation/MTEElectricAutoWorkbench.java | 864 ++++++++++++++ .../automation/MTETesseractGenerator.java | 832 +++++++++++++ .../automation/MTETesseractTerminal.java | 642 ++++++++++ .../generators/GT_MetaTileEntity_Boiler_Base.java | 332 ------ .../generators/GT_MetaTileEntity_Boiler_HV.java | 51 - .../generators/GT_MetaTileEntity_Boiler_LV.java | 51 - .../generators/GT_MetaTileEntity_Boiler_MV.java | 51 - .../GT_MetaTileEntity_SemiFluidGenerator.java | 162 --- .../GregtechMetaTileEntityGeothermalGenerator.java | 171 --- .../GregtechMetaTileEntityRocketFuelGenerator.java | 145 --- .../generators/GregtechMetaTileEntity_RTG.java | 379 ------ .../tileentities/generators/MTEBoilerBase.java | 332 ++++++ .../tileentities/generators/MTEBoilerHV.java | 51 + .../tileentities/generators/MTEBoilerLV.java | 51 + .../tileentities/generators/MTEBoilerMV.java | 51 + .../generators/MTEGeothermalGenerator.java | 166 +++ .../tileentities/generators/MTERTGenerator.java | 379 ++++++ .../generators/MTERocketFuelGenerator.java | 140 +++ .../generators/MTESemiFluidGenerator.java | 161 +++ .../basic/GT_MetaTileEntity_CropHarvestor.java | 706 ----------- .../GregtechMetaAtmosphericReconditioner.java | 889 -------------- .../basic/GregtechMetaPollutionCreator.java | 458 ------- .../basic/GregtechMetaPollutionDetector.java | 502 -------- .../basic/GregtechMetaTileEntity_AutoChisel.java | 185 --- .../basic/GregtechMetaWirelessCharger.java | 672 ----------- .../basic/MTEAtmosphericReconditioner.java | 887 ++++++++++++++ .../tileentities/machines/basic/MTEAutoChisel.java | 184 +++ .../machines/basic/MTECropHarvestor.java | 706 +++++++++++ .../machines/basic/MTEPollutionCreator.java | 459 +++++++ .../machines/basic/MTEPollutionDetector.java | 503 ++++++++ .../machines/basic/MTEWirelessCharger.java | 672 +++++++++++ .../machines/multi/misc/GMTE_AmazonPackager.java | 248 ---- .../machines/multi/misc/MTEAmazonPackager.java | 246 ++++ ...gtechMetaTileEntity_IndustrialAlloySmelter.java | 223 ---- ...regtechMetaTileEntity_IndustrialArcFurnace.java | 359 ------ ...regtechMetaTileEntity_IndustrialCentrifuge.java | 228 ---- .../GregtechMetaTileEntity_IndustrialChisel.java | 342 ------ .../GregtechMetaTileEntity_IndustrialCokeOven.java | 209 ---- ...echMetaTileEntity_IndustrialCuttingMachine.java | 270 ----- ...regtechMetaTileEntity_IndustrialDehydrator.java | 278 ----- ...gtechMetaTileEntity_IndustrialElectrolyzer.java | 169 --- .../GregtechMetaTileEntity_IndustrialExtruder.java | 194 --- ...egtechMetaTileEntity_IndustrialFluidHeater.java | 204 ---- ...egtechMetaTileEntity_IndustrialForgeHammer.java | 244 ---- ...GregtechMetaTileEntity_IndustrialMacerator.java | 390 ------ .../GregtechMetaTileEntity_IndustrialMixer.java | 211 ---- ...aTileEntity_IndustrialMolecularTransformer.java | 241 ---- ...gtechMetaTileEntity_IndustrialMultiMachine.java | 541 --------- ...regtechMetaTileEntity_IndustrialPlatePress.java | 262 ---- .../GregtechMetaTileEntity_IndustrialSifter.java | 209 ---- ...MetaTileEntity_IndustrialThermalCentrifuge.java | 184 --- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 256 ---- ...GregtechMetaTileEntity_IndustrialWashPlant.java | 425 ------- .../GregtechMetaTileEntity_IndustrialWireMill.java | 213 ---- .../processing/GregtechMetaTileEntity_IsaMill.java | 529 --------- ...hMetaTileEntity_NuclearSaltProcessingPlant.java | 224 ---- .../GregtechMetaTileEntity_SpargeTower.java | 507 -------- .../processing/MTEIndustrialAlloySmelter.java | 221 ++++ .../multi/processing/MTEIndustrialArcFurnace.java | 359 ++++++ .../multi/processing/MTEIndustrialCentrifuge.java | 228 ++++ .../multi/processing/MTEIndustrialChisel.java | 340 ++++++ .../multi/processing/MTEIndustrialCokeOven.java | 208 ++++ .../processing/MTEIndustrialCuttingMachine.java | 269 +++++ .../multi/processing/MTEIndustrialDehydrator.java | 274 +++++ .../multi/processing/MTEIndustrialExtruder.java | 193 +++ .../multi/processing/MTEIndustrialFluidHeater.java | 204 ++++ .../multi/processing/MTEIndustrialForgeHammer.java | 244 ++++ .../multi/processing/MTEIndustrialMacerator.java | 389 ++++++ .../multi/processing/MTEIndustrialMixer.java | 210 ++++ .../MTEIndustrialMolecularTransformer.java | 239 ++++ .../processing/MTEIndustrialMultiMachine.java | 540 +++++++++ .../multi/processing/MTEIndustrialPlatePress.java | 262 ++++ .../multi/processing/MTEIndustrialSifter.java | 208 ++++ .../processing/MTEIndustrialThermalCentrifuge.java | 183 +++ .../processing/MTEIndustrialVacuumFreezer.java | 254 ++++ .../multi/processing/MTEIndustrialWashPlant.java | 425 +++++++ .../multi/processing/MTEIndustrialWireMill.java | 212 ++++ .../machines/multi/processing/MTEIsaMill.java | 527 +++++++++ .../processing/MTENuclearSaltProcessingPlant.java | 222 ++++ .../machines/multi/processing/MTESpargeTower.java | 498 ++++++++ .../multi/processing/MTEndustrialElectrolyzer.java | 168 +++ ...egtechMetaTileEntity_Adv_DistillationTower.java | 519 -------- .../advanced/GregtechMetaTileEntity_Adv_EBF.java | 328 ----- .../GregtechMetaTileEntity_Adv_Fusion_MK4.java | 200 ---- .../GregtechMetaTileEntity_Adv_Fusion_MK5.java | 200 ---- .../GregtechMetaTileEntity_Adv_HeatExchanger.java | 409 ------- .../GregtechMetaTileEntity_Adv_Implosion.java | 177 --- .../advanced/MTEAdvDistillationTower.java | 504 ++++++++ .../multi/processing/advanced/MTEAdvEBF.java | 323 +++++ .../multi/processing/advanced/MTEAdvFusionMk4.java | 200 ++++ .../multi/processing/advanced/MTEAdvFusionMk5.java | 200 ++++ .../processing/advanced/MTEAdvHeatExchanger.java | 396 +++++++ .../advanced/MTEAdvImplosionCompressor.java | 176 +++ .../GregtechMetaTileEntity_SteamCentrifuge.java | 419 ------- .../GregtechMetaTileEntity_SteamCompressor.java | 352 ------ .../GregtechMetaTileEntity_SteamForgeHammer.java | 409 ------- .../GregtechMetaTileEntity_SteamMacerator.java | 354 ------ .../steam/GregtechMetaTileEntity_SteamMixer.java | 458 ------- .../steam/GregtechMetaTileEntity_SteamWasher.java | 552 --------- .../GregtechMetaTileEntity_SteamWaterPump.java | 374 ------ .../multi/processing/steam/MTESteamCentrifuge.java | 418 +++++++ .../multi/processing/steam/MTESteamCompressor.java | 351 ++++++ .../processing/steam/MTESteamForgeHammer.java | 408 +++++++ .../multi/processing/steam/MTESteamMacerator.java | 353 ++++++ .../multi/processing/steam/MTESteamMixer.java | 457 +++++++ .../multi/processing/steam/MTESteamWasher.java | 551 +++++++++ .../multi/processing/steam/MTESteamWaterPump.java | 373 ++++++ .../multi/production/GT4Entity_AutoCrafter.java | 196 --- .../multi/production/GT4Entity_ThermalBoiler.java | 353 ------ .../GregtechMTE_ElementalDuplicator.java | 352 ------ .../production/GregtechMTE_FrothFlotationCell.java | 287 ----- .../production/GregtechMTE_NuclearReactor.java | 525 -------- .../production/GregtechMetaTileEntityTreeFarm.java | 823 ------------- .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 233 ---- .../GregtechMetaTileEntity_Cyclotron.java | 338 ------ ...egtechMetaTileEntity_IndustrialFishingPond.java | 488 -------- ...egtechMetaTileEntity_IndustrialRockBreaker.java | 366 ------ .../GregtechMetaTileEntity_LargeRocketEngine.java | 524 -------- ...techMetaTileEntity_LargeSemifluidGenerator.java | 332 ------ .../GregtechMetaTileEntity_MassFabricator.java | 361 ------ ...techMetaTileEntity_QuantumForceTransformer.java | 945 --------------- .../GregtechMetaTileEntity_Refinery.java | 220 ---- .../GregtechMetaTileEntity_SolarTower.java | 675 ----------- .../multi/production/MTEAlloyBlastSmelter.java | 232 ++++ .../machines/multi/production/MTEAutoCrafter.java | 195 +++ .../machines/multi/production/MTECyclotron.java | 337 ++++++ .../multi/production/MTEElementalDuplicator.java | 352 ++++++ .../multi/production/MTEFrothFlotationCell.java | 286 +++++ .../multi/production/MTEIndustrialFishingPond.java | 488 ++++++++ .../multi/production/MTEIndustrialRockBreaker.java | 366 ++++++ .../multi/production/MTELargeRocketEngine.java | 523 ++++++++ .../production/MTELargeSemifluidGenerator.java | 331 ++++++ .../multi/production/MTEMassFabricator.java | 360 ++++++ .../multi/production/MTENuclearReactor.java | 521 ++++++++ .../production/MTEQuantumForceTransformer.java | 939 +++++++++++++++ .../machines/multi/production/MTERefinery.java | 218 ++++ .../machines/multi/production/MTESolarTower.java | 672 +++++++++++ .../multi/production/MTEThermalBoiler.java | 352 ++++++ .../machines/multi/production/MTETreeFarm.java | 823 +++++++++++++ .../algae/GregtechMTE_AlgaePondBase.java | 393 ------ .../multi/production/algae/MTEAlgaePondBase.java | 392 ++++++ .../chemplant/GregtechMTE_ChemicalPlant.java | 676 ----------- .../production/chemplant/MTEChemicalPlant.java | 670 +++++++++++ ...egTechMetaTileEntity_MegaAlloyBlastSmelter.java | 497 -------- .../production/mega/MTEMegaAlloyBlastSmelter.java | 494 ++++++++ .../turbines/GT_MTE_LargeTurbine_Gas.java | 208 ---- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 314 ----- .../turbines/GT_MTE_LargeTurbine_SCSteam.java | 126 -- .../turbines/GT_MTE_LargeTurbine_SHSteam.java | 204 ---- .../turbines/GT_MTE_LargeTurbine_Steam.java | 215 ---- .../GregtechMetaTileEntity_LargerTurbineBase.java | 886 -------------- .../production/turbines/MTELargeTurbineGas.java | 208 ++++ .../production/turbines/MTELargeTurbinePlasma.java | 315 +++++ .../turbines/MTELargeTurbineSCSteam.java | 126 ++ .../turbines/MTELargeTurbineSHSteam.java | 204 ++++ .../production/turbines/MTELargeTurbineSteam.java | 215 ++++ .../production/turbines/MTELargerTurbineBase.java | 884 ++++++++++++++ ...chMetaTileEntity_PowerSubStationController.java | 100 +- .../common/tileentities/misc/MTESolarHeater.java | 343 ++++++ .../tileentities/misc/TileEntitySolarHeater.java | 343 ------ .../redstone/GT_MetaTileEntity_RedstoneBase.java | 111 -- .../GT_MetaTileEntity_RedstoneButtonPanel.java | 205 ---- .../GT_MetaTileEntity_RedstoneCircuitBlock.java | 654 ---------- .../redstone/GT_MetaTileEntity_RedstoneLamp.java | 73 -- .../GT_MetaTileEntity_RedstoneStrengthDisplay.java | 139 --- .../GT_MetaTileEntity_RedstoneStrengthScale.java | 54 - .../tileentities/redstone/MTERedstoneBase.java | 111 ++ .../redstone/MTERedstoneButtonPanel.java | 204 ++++ .../redstone/MTERedstoneCircuitBlock.java | 652 ++++++++++ .../tileentities/redstone/MTERedstoneLamp.java | 73 ++ .../redstone/MTERedstoneStrengthDisplay.java | 138 +++ .../redstone/MTERedstoneStrengthScale.java | 53 + .../storage/GT_MetaTileEntity_TieredChest.java | 245 ---- .../storage/GT_MetaTileEntity_TieredTank.java | 189 --- .../storage/GregtechMetaEnergyBuffer.java | 439 ------- .../tileentities/storage/MTEEnergyBuffer.java | 434 +++++++ .../tileentities/storage/MTETieredChest.java | 245 ++++ .../common/tileentities/storage/MTETieredTank.java | 188 +++ .../GT_MetaTileEntity_InfiniteItemHolder.java | 92 -- .../storage/creative/MTEInfiniteItemHolder.java | 91 ++ .../common/tools/TOOL_Gregtech_AngleGrinder.java | 175 --- .../common/tools/TOOL_Gregtech_ElectricSnips.java | 96 -- .../gregtech/common/tools/ToolAngleGrinder.java | 175 +++ .../gregtech/common/tools/ToolElectricSnips.java | 96 ++ 233 files changed, 35277 insertions(+), 35431 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/MetaGTProxy.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverOverflow.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverToggleVisual.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GTMethodHelper.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/items/Ids_MetaGeneratedGregtechItems.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedItemIDs.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTEElectricAutoWorkbench.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractTerminal.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerBase.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerHV.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerLV.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerMV.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEGeothermalGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERocketFuelGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTESemiFluidGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/MTEAmazonPackager.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialAlloySmelter.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialArcFurnace.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCokeOven.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCuttingMachine.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialExtruder.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialFluidHeater.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialForgeHammer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMacerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMixer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMolecularTransformer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMultiMachine.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialPlatePress.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialSifter.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialThermalCentrifuge.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialVacuumFreezer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWashPlant.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWireMill.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIsaMill.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTENuclearSaltProcessingPlant.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTESpargeTower.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEndustrialElectrolyzer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK5.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvEBF.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk4.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk5.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvImplosionCompressor.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCentrifuge.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamForgeHammer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMixer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWasher.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWaterPump.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCentrifuge.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamForgeHammer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMacerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMixer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWasher.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWaterPump.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAlloyBlastSmelter.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAutoCrafter.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEFrothFlotationCell.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialRockBreaker.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeSemifluidGenerator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEMassFabricator.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEThermalBoiler.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/MTEMegaAlloyBlastSmelter.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/MTESolarHeater.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneBase.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneButtonPanel.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneCircuitBlock.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneLamp.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthDisplay.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthScale.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTEEnergyBuffer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredChest.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredTank.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/MTEInfiniteItemHolder.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolAngleGrinder.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolElectricSnips.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/MetaGTProxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/MetaGTProxy.java new file mode 100644 index 0000000000..fbef4832e5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/MetaGTProxy.java @@ -0,0 +1,96 @@ +package gtPlusPlus.xmod.gregtech.common; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TAE; +import gregtech.api.util.GTLanguageManager; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.AchievementHandler; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.LangUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; + +public class MetaGTProxy { + + public static AchievementHandler mAssemblyAchievements; + + public MetaGTProxy() {} + + public static void preInit() { + fixIC2FluidNames(); + CoverManager.generateCustomCovers(); + } + + public static void init() { + PollutionUtils.setPollutionFluids(); + fixIC2FluidNames(); + } + + public static void postInit() { + mAssemblyAchievements = new AchievementHandler(); + fixIC2FluidNames(); + + // Finalise TAE + TAE.finalizeTAE(); + } + + @SuppressWarnings("deprecation") + public static void fixIC2FluidNames() { + // Fix IC2 Hot Water name + try { + String aNewHeatedWaterName = "Heated Water"; + Logger.INFO("Renaming [IC2 Hotspring Water] --> [" + aNewHeatedWaterName + "]."); + LanguageRegistry.instance() + .addStringLocalization("fluidHotWater", "Heated Water"); + LanguageRegistry.instance() + .addStringLocalization("fluidHotWater", aNewHeatedWaterName); + LanguageRegistry.instance() + .addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + GTLanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); + GTLanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + + Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); + if (b != null) { + LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); + LanguageRegistry.instance() + .addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + GTLanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + } + Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); + if (f != null) { + LanguageRegistry.instance() + .addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + GTLanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + int aDam = FluidRegistry.getFluidID(f); + ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); + if (s != null) { + LanguageRegistry.addName(s, aNewHeatedWaterName); + } + } + + String[] aLangs = new String[] { "de_DE", "en_US", "en_GB", "en_IC", "es_AR", "es_ES", "es_MX", "es_UY", + "es_VE", "fr_CA", "fr_FR", "it_IT", "ko_KR", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "tr_TR", "zh_CN", + "zh_TW", }; + String[] aLangValues = new String[] { "Erhitztes Wasser", "Heated Water", "Heated Water", "Heated Water", + "Agua caliente", "Agua caliente", "Agua caliente", "Agua caliente", "Agua caliente", "Eau chauffée", + "Eau chauffée", "Acqua riscaldata", "온수", "Água aquecida", "Água aquecida", "Вода с подогревом", + "Uppvärmt vatten", "Isıtılmış Su", "热水", "热水", }; + for (int i = 0; i < aLangs.length; i++) { + Logger + .REFLECTION("Trying to inject new lang data for " + aLangs[i] + ", using value: " + aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]); + } + } catch (Throwable t) { + + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java deleted file mode 100644 index c53e217560..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ /dev/null @@ -1,96 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -import cpw.mods.fml.common.registry.LanguageRegistry; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.TAE; -import gregtech.api.util.GT_LanguageManager; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.handler.AchievementHandler; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.LangUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; - -public class Meta_GT_Proxy { - - public static AchievementHandler mAssemblyAchievements; - - public Meta_GT_Proxy() {} - - public static void preInit() { - fixIC2FluidNames(); - CoverManager.generateCustomCovers(); - } - - public static void init() { - PollutionUtils.setPollutionFluids(); - fixIC2FluidNames(); - } - - public static void postInit() { - mAssemblyAchievements = new AchievementHandler(); - fixIC2FluidNames(); - - // Finalise TAE - TAE.finalizeTAE(); - } - - @SuppressWarnings("deprecation") - public static void fixIC2FluidNames() { - // Fix IC2 Hot Water name - try { - String aNewHeatedWaterName = "Heated Water"; - Logger.INFO("Renaming [IC2 Hotspring Water] --> [" + aNewHeatedWaterName + "]."); - LanguageRegistry.instance() - .addStringLocalization("fluidHotWater", "Heated Water"); - LanguageRegistry.instance() - .addStringLocalization("fluidHotWater", aNewHeatedWaterName); - LanguageRegistry.instance() - .addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - - Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); - if (b != null) { - LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); - LanguageRegistry.instance() - .addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - } - Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); - if (f != null) { - LanguageRegistry.instance() - .addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - int aDam = FluidRegistry.getFluidID(f); - ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); - if (s != null) { - LanguageRegistry.addName(s, aNewHeatedWaterName); - } - } - - String[] aLangs = new String[] { "de_DE", "en_US", "en_GB", "en_IC", "es_AR", "es_ES", "es_MX", "es_UY", - "es_VE", "fr_CA", "fr_FR", "it_IT", "ko_KR", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "tr_TR", "zh_CN", - "zh_TW", }; - String[] aLangValues = new String[] { "Erhitztes Wasser", "Heated Water", "Heated Water", "Heated Water", - "Agua caliente", "Agua caliente", "Agua caliente", "Agua caliente", "Agua caliente", "Eau chauffée", - "Eau chauffée", "Acqua riscaldata", "온수", "Água aquecida", "Água aquecida", "Вода с подогревом", - "Uppvärmt vatten", "Isıtılmış Su", "热水", "热水", }; - for (int i = 0; i < aLangs.length; i++) { - Logger - .REFLECTION("Trying to inject new lang data for " + aLangs[i] + ", using value: " + aLangValues[i]); - LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]); - LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]); - } - } catch (Throwable t) { - - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java index ee0d040394..ef9274af1d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java @@ -8,10 +8,10 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler; public class GregtechMetaCasingBlocks extends GregtechMetaCasingBlocksAbstract { @@ -19,32 +19,31 @@ public class GregtechMetaCasingBlocks extends GregtechMetaCasingBlocksAbstract { CasingTextureHandler TextureHandler = new CasingTextureHandler(); public GregtechMetaCasingBlocks() { - super(GregtechMetaCasingItems.class, "miscutils.blockcasings", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItems.class, "miscutils.blockcasings", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { if (i == 2 || i == 3 || i == 4) { continue; } - TAE.registerTexture(0, i, new GTPP_CopiedBlockTexture(this, 6, i)); + TAE.registerTexture(0, i, new GTPPCopiedBlockTexture(this, 6, i)); } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Centrifuge Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Structural Coke Oven Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Centrifuge Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Structural Coke Oven Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".2.name", "Heat Resistant Coke Oven Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Heat Proof Coke Oven Casing"); // 60 - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".4.name", "Material Press Machine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Electrolyzer Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Wire Factory Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Maceration Stack Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Matter Generation Coil"); // 65 - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Matter Fabricator Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Iron Plated Bricks"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Heat Proof Coke Oven Casing"); // 60 + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Material Press Machine Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Electrolyzer Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Wire Factory Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Maceration Stack Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Matter Generation Coil"); // 65 + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Matter Fabricator Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Iron Plated Bricks"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".14.name", "Blast Smelter Heat Containment Coil "); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); GregtechItemList.Casing_Centrifuge1.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_CokeOven.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_CokeOven_Coil1.set(new ItemStack(this, 1, 2)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 9d53c281a2..eefc983e21 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -10,11 +10,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import gregtech.api.enums.TAE; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler2; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; @@ -53,38 +53,38 @@ public class GregtechMetaCasingBlocks2 extends GregtechMetaCasingBlocksAbstract int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); if (meta == 7 && tier > 0) { long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); - aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + aList.add("Energy Storage: " + GTUtility.formatNumbers(capacity)); } super.addInformation(aStack, aPlayer, aList, aF3_H); } } public GregtechMetaCasingBlocks2() { - super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { if (i == 4 || i == 10 || i == 11 || i == 12 || i == 14) { continue; } - TAE.registerTexture(1, i, new GTPP_CopiedBlockTexture(this, 6, i)); + TAE.registerTexture(1, i, new GTPPCopiedBlockTexture(this, 6, i)); } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Thermal Processing Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Thermal Processing Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (EV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Bulk Production Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Bulk Production Frame"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 76fb077de1..0a5399efdc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -11,11 +11,11 @@ import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler3; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; @@ -37,46 +37,45 @@ public class GregtechMetaCasingBlocks3 extends GregtechMetaCasingBlocksAbstract int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); if (tier > 0) { long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); - aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + aList.add("Energy Storage: " + GTUtility.formatNumbers(capacity)); } super.addInformation(aStack, aPlayer, aList, aF3_H); } } public GregtechMetaCasingBlocks3() { - super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { // Free up Redox casing in TAE if (i >= 4 && i <= 8) { continue; } - TAE.registerTexture(2, i, new GTPP_CopiedBlockTexture(this, 6, i)); + TAE.registerTexture(2, i, new GTPPCopiedBlockTexture(this, 6, i)); } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".4.name", "Vanadium Redox Power Cell (IV)"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".5.name", "Vanadium Redox Power Cell (LuV)"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".6.name", "Vanadium Redox Power Cell (ZPM)"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (UV)"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".8.name", "Vanadium Redox Power Cell (UHV)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Supply Depot Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Advanced Cryogenic Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Unnamed"); // Can Use, don't - // change texture - // (Used for Fusion - // MK4) - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Supply Depot Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Advanced Cryogenic Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Unnamed"); // Can Use, don't + // change texture + // (Used for Fusion + // MK4) + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_Multi_Use.set(new ItemStack(this, 1, 2)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index a150d7e828..d68653e73a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -9,30 +9,30 @@ import net.minecraft.util.IIcon; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GregtechMetaCasingBlocks4 extends GregtechMetaCasingBlocksAbstract { public GregtechMetaCasingBlocks4() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.4", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.4", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { if (i == 2 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 12 || i == 13 || i == 14 || i == 15) { continue; } - TAE.registerTexture(3, i, new GTPP_CopiedBlockTexture(this, 6, i)); + TAE.registerTexture(3, i, new GTPPCopiedBlockTexture(this, 6, i)); } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Naquadah Reactor Base"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reactor Piping"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Naquadah Containment Chamber"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Tempered Arc Furnace Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Naquadah Reactor Base"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reactor Piping"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Naquadah Containment Chamber"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Tempered Arc Furnace Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".4.name", "Quantum Force Transformer Coil Casings"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); GregtechItemList.Casing_Naq_Reactor_A.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Naq_Reactor_B.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java index cc573cd188..afe195d7aa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -8,10 +8,10 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGrinderMultiblock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -23,37 +23,36 @@ public class GregtechMetaCasingBlocks5 extends GregtechMetaCasingBlocksAbstract private static final TexturesGrinderMultiblock mGrinderOverlayHandler = new TexturesGrinderMultiblock(); public GregtechMetaCasingBlocks5() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.5", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill - // Casing - TAE.registerTexture(0, 2, new GTPP_CopiedBlockTexture(this, 6, 0)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill - // Pipe - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill - // Gearbox - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.5", MaterialCasings.INSTANCE); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill + // Casing + TAE.registerTexture(0, 2, new GTPPCopiedBlockTexture(this, 6, 0)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill + // Pipe + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill + // Gearbox + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator + // Casing + TAE.registerTexture(0, 3, new GTPPCopiedBlockTexture(this, 6, 3)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge + // Tower // Casing - TAE.registerTexture(0, 3, new GTPP_CopiedBlockTexture(this, 6, 3)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge - // Tower - // Casing - TAE.registerTexture(0, 4, new GTPP_CopiedBlockTexture(this, 6, 4)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Sturdy Printer Casing"); // Unused - TAE.registerTexture(1, 10, new GTPP_CopiedBlockTexture(this, 6, 5)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Forge Casing"); // Forge Hammer - // Casing - TAE.registerTexture(1, 11, new GTPP_CopiedBlockTexture(this, 6, 6)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Neutron Pulse Manipulator"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Cosmic Fabric Manipulator"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Infinity Infused Manipulator"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "SpaceTime Continuum Ripper"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Neutron Shielding Core"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".12.name", "Cosmic Fabric Shielding Core"); - GT_LanguageManager + TAE.registerTexture(0, 4, new GTPPCopiedBlockTexture(this, 6, 4)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Sturdy Printer Casing"); // Unused + TAE.registerTexture(1, 10, new GTPPCopiedBlockTexture(this, 6, 5)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Forge Casing"); // Forge Hammer + // Casing + TAE.registerTexture(1, 11, new GTPPCopiedBlockTexture(this, 6, 6)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Neutron Pulse Manipulator"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Cosmic Fabric Manipulator"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Infinity Infused Manipulator"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "SpaceTime Continuum Ripper"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Neutron Shielding Core"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Cosmic Fabric Shielding Core"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".13.name", "Infinity Infused Shielding Core"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "SpaceTime Bending Core"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Force Field Glass"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "SpaceTime Bending Core"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Force Field Glass"); GregtechItemList.Casing_IsaMill_Casing.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_IsaMill_Pipe.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks6.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks6.java index d257078461..c51d6e6afd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks6.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks6.java @@ -13,10 +13,10 @@ import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler6; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -45,13 +45,13 @@ public class GregtechMetaCasingBlocks6 extends GregtechMetaCasingBlocksAbstract } public GregtechMetaCasingBlocks6() { - super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.6", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Fusion Machine Casing MK IV"); - TAE.registerTexture(3, 4, new GTPP_CopiedBlockTexture(this, 6, 0)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Advanced Fusion Coil II"); - TAE.registerTexture(3, 5, new GTPP_CopiedBlockTexture(this, 6, 1)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Unnamed"); - TAE.registerTexture(3, 6, new GTPP_CopiedBlockTexture(this, 6, 2)); + super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.6", MaterialCasings.INSTANCE); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Fusion Machine Casing MK IV"); + TAE.registerTexture(3, 4, new GTPPCopiedBlockTexture(this, 6, 0)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Advanced Fusion Coil II"); + TAE.registerTexture(3, 5, new GTPPCopiedBlockTexture(this, 6, 1)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Unnamed"); + TAE.registerTexture(3, 6, new GTPPCopiedBlockTexture(this, 6, 2)); GregtechItemList.Casing_Fusion_External2.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Fusion_Internal2.set(new ItemStack(this, 1, 1)); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java index 79d9e2c458..f286b4d628 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java @@ -19,20 +19,20 @@ 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.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Block_Casings_Abstract; +import gregtech.api.GregTechAPI; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; import gtPlusPlus.core.creative.AddToCreativeTab; -public abstract class GregtechMetaCasingBlocksAbstract extends GT_Block_Casings_Abstract { +public abstract class GregtechMetaCasingBlocksAbstract extends BlockCasingsAbstract { public GregtechMetaCasingBlocksAbstract(final Class aItemClass, final String aName, final Material aMaterial) { super(aItemClass, aName, aMaterial); this.setStepSound(soundTypeMetal); this.setCreativeTab(AddToCreativeTab.tabMachines); - GregTech_API.registerMachineBlock(this, -1); - GT_LanguageManager + GregTechAPI.registerMachineBlock(this, -1); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); } @@ -63,8 +63,8 @@ public abstract class GregtechMetaCasingBlocksAbstract extends GT_Block_Casings_ @Override public void onBlockAdded(final World aWorld, final int aX, final int aY, final int aZ) { - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); } } @@ -106,8 +106,8 @@ public abstract class GregtechMetaCasingBlocksAbstract extends GT_Block_Casings_ @Override public void breakBlock(final World aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final int aMetaData) { - if (GregTech_API.isMachineBlock(this, aMetaData)) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java index ad2b11f924..32f1f127d0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksPipeGearbox.java @@ -8,9 +8,9 @@ import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; -import gtPlusPlus.core.material.ALLOY; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; +import gtPlusPlus.core.material.MaterialsAlloy; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GregtechMetaCasingBlocksPipeGearbox extends GregtechMetaCasingBlocksAbstract { @@ -18,42 +18,41 @@ public class GregtechMetaCasingBlocksPipeGearbox extends GregtechMetaCasingBlock private static HashMap sMaterialMapping = new HashMap<>(); public GregtechMetaCasingBlocksPipeGearbox() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.pipesgears", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Eglin Steel Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel-792 Gear Box Casing"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".2.name", "Incoloy MA956 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Nitinol-60 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Zeron-100 Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Pikyonium Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Titansteel Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Abyssal Gear Box Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Babbit Alloy Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Inconel-690 Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Stellite Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Nitinol-60 Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Lafium Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cinobite Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Titansteel Pipe Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Abyssal Pipe Casing"); + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.pipesgears", MaterialCasings.INSTANCE); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Eglin Steel Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel-792 Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Incoloy MA956 Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Nitinol-60 Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Zeron-100 Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Pikyonium Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Titansteel Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Abyssal Gear Box Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Babbit Alloy Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Inconel-690 Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Stellite Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Nitinol-60 Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Lafium Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cinobite Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Titansteel Pipe Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Abyssal Pipe Casing"); int aMappingID = 0; - sMaterialMapping.put(aMappingID++, ALLOY.EGLIN_STEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_792.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCOLOY_MA956.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ZERON_100.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.PIKYONIUM.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.BABBIT_ALLOY.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.INCONEL_690.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.STELLITE.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.NITINOL_60.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.LAFIUM.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.CINOBITE.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.TITANSTEEL.getRgbAsHex()); - sMaterialMapping.put(aMappingID++, ALLOY.ABYSSAL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.EGLIN_STEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.INCONEL_792.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.INCOLOY_MA956.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.NITINOL_60.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.ZERON_100.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.PIKYONIUM.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.TITANSTEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.ABYSSAL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.BABBIT_ALLOY.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.INCONEL_690.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.STELLITE.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.NITINOL_60.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.LAFIUM.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.CINOBITE.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.TITANSTEEL.getRgbAsHex()); + sMaterialMapping.put(aMappingID++, MaterialsAlloy.ABYSSAL.getRgbAsHex()); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java index 23d9ab5007..a432212670 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java @@ -7,21 +7,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GTLanguageManager; public abstract class GregtechMetaItemCasingsAbstract extends ItemBlock { - protected final String mCasing_Centrifuge = GT_LanguageManager + protected final String mCasing_Centrifuge = GTLanguageManager .addStringLocalization("mu.centrifugecasing", "Warning! Standing in the Centrifuge not recommended"); - protected final String mCasing_CokeOven = GT_LanguageManager + protected final String mCasing_CokeOven = GTLanguageManager .addStringLocalization("mu.cokeoven", "Sturdy and Strong"); - protected final String mCasing_CokeCoil1 = GT_LanguageManager + protected final String mCasing_CokeCoil1 = GTLanguageManager .addStringLocalization("mu.coil01tooltip", "Base Heating Capacity = 1350 Kelvin"); - protected final String mCasing_CokeCoil2 = GT_LanguageManager + protected final String mCasing_CokeCoil2 = GTLanguageManager .addStringLocalization("mu.coil02tooltip", "Base Heating Capacity = 2275 Kelvin"); - protected final String mNoMobsToolTip = GT_LanguageManager + protected final String mNoMobsToolTip = GTLanguageManager .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); - protected final String mNoTileEntityToolTip = GT_LanguageManager + protected final String mNoTileEntityToolTip = GTLanguageManager .addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); public GregtechMetaItemCasingsAbstract(final Block par1) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java index 473c13f3da..7c65de73bd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java @@ -11,10 +11,10 @@ import net.minecraft.util.IIcon; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksAbstract { @@ -43,19 +43,18 @@ public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksA } public GregtechMetaSpecialMachineCasings() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", GT_Material_Casings.INSTANCE); + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { // TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); - TAE.registerTexture(84, new GTPP_CopiedBlockTexture(this, 6, 2)); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); + TAE.registerTexture(84, new GTPPCopiedBlockTexture(this, 6, 2)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); GregtechItemList.Casing_Machine_Custom_1.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Machine_Custom_2.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index 1d7c853e71..dba95455c8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -13,10 +13,10 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; +import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler; @@ -39,32 +39,29 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs } public GregtechMetaSpecialMultiCasings() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.1", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Turbine Shaft"); - GT_LanguageManager + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.1", MaterialCasings.INSTANCE); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Turbine Shaft"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reinforced Steam Turbine Casing"); - GT_LanguageManager + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".2.name", "Reinforced HP Steam Turbine Casing"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".3.name", "Reinforced Gas Turbine Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Reinforced Gas Turbine Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".4.name", "Reinforced Plasma Turbine Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Tesla Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".11.name", "Molecular Containment Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Tesla Containment Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Molecular Containment Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".12.name", "High Voltage Current Capacitor"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Particle Containment Casing"); - GT_LanguageManager + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Particle Containment Casing"); + GTLanguageManager .addStringLocalization(this.getUnlocalizedName() + ".14.name", "Reinforced Heat Exchanger Casing"); - GT_LanguageManager - .addStringLocalization(this.getUnlocalizedName() + ".15.name", "Reinforced SC Turbine Casing"); - TAE.registerTexture(1, 12, new GTPP_CopiedBlockTexture(this, 6, 14)); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Reinforced SC Turbine Casing"); + TAE.registerTexture(1, 12, new GTPPCopiedBlockTexture(this, 6, 14)); GregtechItemList.Casing_Turbine_Shaft.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Turbine_LP.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java index 9a2912c2c5..4f34811289 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings2.java @@ -13,8 +13,8 @@ import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -47,19 +47,19 @@ public class GregtechMetaSpecialMultiCasings2 extends GregtechMetaCasingBlocksAb } public GregtechMetaSpecialMultiCasings2() { - super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.3", GT_Material_Casings.INSTANCE); + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.3", MaterialCasings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { // TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) } - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Resonance Chamber I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Resonance Chamber II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Resonance Chamber III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Resonance Chamber IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Modulator I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Modulator II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Modulator III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Modulator IV"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Resonance Chamber I"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Resonance Chamber II"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Resonance Chamber III"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Resonance Chamber IV"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Modulator I"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Modulator II"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Modulator III"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Modulator IV"); GregtechItemList.ResonanceChamber_I.set(new ItemStack(this, 1, 0)); GregtechItemList.ResonanceChamber_II.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java index 7ddab1c471..50780c5809 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java @@ -9,10 +9,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import gregtech.api.enums.GT_Values; +import gregtech.api.enums.GTValues; import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Material_Casings; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.MaterialCasings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -35,24 +35,24 @@ public class GregtechMetaTieredCasingBlocks1 extends GregtechMetaCasingBlocksAbs public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { int aMeta = aStack.getItemDamage(); if (aMeta < 10) { - aList.add("Tier: " + GT_Values.VN[aMeta]); + aList.add("Tier: " + GTValues.VN[aMeta]); } super.addInformation(aStack, aPlayer, aList, aF3_H); } } public GregtechMetaTieredCasingBlocks1() { - super(TieredCasingItemBlock.class, "gtplusplus.blocktieredcasings.1", GT_Material_Casings.INSTANCE); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Integral Encasement I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Integral Encasement II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Integral Encasement III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Integral Encasement IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Integral Encasement V"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Integral Framework I"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Integral Framework II"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Integral Framework III"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Integral Framework IV"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Integral Framework V"); + super(TieredCasingItemBlock.class, "gtplusplus.blocktieredcasings.1", MaterialCasings.INSTANCE); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Integral Encasement I"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Integral Encasement II"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Integral Encasement III"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Integral Encasement IV"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Integral Encasement V"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Integral Framework I"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Integral Framework II"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Integral Framework III"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Integral Framework IV"); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Integral Framework V"); GregtechItemList.GTPP_Casing_ULV.set(new ItemStack(this, 1, 0)); GregtechItemList.GTPP_Casing_LV.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java index 30658ab6ef..0f1c39d28e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java @@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GTOreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -28,7 +28,7 @@ public class GregtechFluidHandler { GT_Materials.Cryotheum, 4, 5, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Cryotheum, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.Cryotheum, 1L), ItemUtils.getEmptyCell(), 1000); } @@ -39,7 +39,7 @@ public class GregtechFluidHandler { GT_Materials.Pyrotheum, 4, 4000, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Pyrotheum, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.Pyrotheum, 1L), ItemUtils.getEmptyCell(), 1000); } @@ -50,7 +50,7 @@ public class GregtechFluidHandler { GT_Materials.Ender, 4, 4000, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Ender, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.Ender, 1L), ItemUtils.getEmptyCell(), 1000); } @@ -62,7 +62,7 @@ public class GregtechFluidHandler { GT_Materials.HydrofluoricAcid, 1, 120, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); @@ -80,7 +80,7 @@ public class GregtechFluidHandler { GT_Materials.SulfurousAcid, 4, 75, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); @@ -92,7 +92,7 @@ public class GregtechFluidHandler { GT_Materials.SulfuricApatite, 4, 500, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), ItemUtils.getEmptyCell(), 1000, false); @@ -106,7 +106,7 @@ public class GregtechFluidHandler { GT_Materials.HydrogenChloride, 4, 75, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), ItemUtils.getEmptyCell(), 1000, false); @@ -119,7 +119,7 @@ public class GregtechFluidHandler { GT_Materials.SulfuricLithium, 4, 280, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricLithium, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricLithium, 1L), ItemUtils.getEmptyCell(), 1000, false); @@ -131,7 +131,7 @@ public class GregtechFluidHandler { GT_Materials.LithiumHydroxide, 4, 500, - GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.LithiumHydroxide, 1L), + GTOreDictUnificator.get(OrePrefixes.cell, GT_Materials.LithiumHydroxide, 1L), ItemUtils.getEmptyCell(), 1000, false); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java index 058d2a7f1e..f4d3d22aba 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -9,7 +9,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.MTEIndustrialCentrifuge; public class TexturesCentrifugeMultiblock { @@ -67,8 +67,8 @@ public class TexturesCentrifugeMultiblock { ForgeDirection side) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialCentrifuge - && tTile.getFrontFacing() == side) return tTile.isActive() ? 1 : 2; + if (tTile.getMetaTileEntity() instanceof MTEIndustrialCentrifuge && tTile.getFrontFacing() == side) + return tTile.isActive() ? 1 : 2; return 0; } @@ -133,8 +133,8 @@ public class TexturesCentrifugeMultiblock { public boolean isUsingAnimatedTexture(IMetaTileEntity aMetaTileEntity) { if (aMetaTileEntity != null) { - if (aMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge) { - return ((GregtechMetaTileEntity_IndustrialCentrifuge) aMetaTileEntity).usingAnimations(); + if (aMetaTileEntity instanceof MTEIndustrialCentrifuge) { + return ((MTEIndustrialCentrifuge) aMetaTileEntity).usingAnimations(); } } return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java index e7d09bd308..128e9c95d7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java @@ -9,7 +9,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks5; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.MTEIsaMill; public class TexturesGrinderMultiblock { @@ -61,7 +61,7 @@ public class TexturesGrinderMultiblock { private static int isIsaControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IsaMill && tTile.getFrontFacing() == side) + if (tTile.getMetaTileEntity() instanceof MTEIsaMill && tTile.getFrontFacing() == side) return tTile.isActive() ? 1 : 2; return 0; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7b58e35a68..57d01bcc5f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -6,17 +6,17 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import gregtech.api.GregTech_API; +import gregtech.api.GregTechAPI; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.GTRenderedTexture; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.GTPPCore; public class TexturesGtBlock { - private static final boolean mAnimated = CORE.ConfigSwitches.enableAnimatedTextures; + private static final boolean mAnimated = GTPPCore.ConfigSwitches.enableAnimatedTextures; private static final AutoMap mCustomiconMap = new AutoMap<>(); /* @@ -38,7 +38,7 @@ public class TexturesGtBlock { this.mModID = aModID; mCustomiconMap.put(this); Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); - GregTech_API.sGTBlockIconload.add(this); + GregTechAPI.sGTBlockIconload.add(this); } @Override @@ -53,7 +53,7 @@ public class TexturesGtBlock { @Override public void run() { - this.mIcon = GregTech_API.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); + this.mIcon = GregTechAPI.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); Logger.WARNING( "FIND ME _ Processing texture: " + this.getTextureFile() .getResourcePath()); @@ -565,16 +565,16 @@ public class TexturesGtBlock { public static final CustomIcon TEXTURE_TECH_PANEL_H = new CustomIcon("metro/TEXTURE_TECH_PANEL_H"); public static ITexture[] OVERLAYS_ENERGY_OUT_MULTI_BUFFER = new ITexture[] { - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 220, 220, 220, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 220, 220, 220, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 255, 100, 0, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 255, 255, 30, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 128, 128, 128, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), - new GT_RenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }) }; + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI_BUFFER, new short[] { 240, 240, 245, 0 }) }; public static IIconContainer[] CONNECTED_FUSION_HULLS = new IIconContainer[] { TEXTURE_CASING_FUSION_COIL_II_1, TEXTURE_CASING_FUSION_COIL_II_2, TEXTURE_CASING_FUSION_COIL_II_3, TEXTURE_CASING_FUSION_COIL_II_4, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java index a9f74cd75d..bf16555e4f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java @@ -6,7 +6,7 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import gregtech.api.GregTech_API; +import gregtech.api.GregTechAPI; import gregtech.api.interfaces.IIconContainer; import gtPlusPlus.api.objects.Logger; @@ -23,7 +23,7 @@ public final class TexturesGtTools { public CustomIcon(final String aIconName) { this.mIconName = aIconName; Logger.INFO("Constructing a Custom Texture. " + this.mIconName); - GregTech_API.sGTItemIconload.add(this); + GregTechAPI.sGTItemIconload.add(this); } @Override @@ -38,9 +38,9 @@ public final class TexturesGtTools { @Override public void run() { - this.mIcon = GregTech_API.sItemIcons.registerIcon(GTPlusPlus.ID + ":" + this.mIconName); + this.mIcon = GregTechAPI.sItemIcons.registerIcon(GTPlusPlus.ID + ":" + this.mIconName); // Utils.LOG_INFO("Registering a Custom Texture. "+mIcon.g); - this.mOverlay = GregTech_API.sItemIcons.registerIcon(GTPlusPlus.ID + ":" + this.mIconName + "_OVERLAY"); + this.mOverlay = GregTechAPI.sItemIcons.registerIcon(GTPlusPlus.ID + ":" + this.mIconName + "_OVERLAY"); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java index c983044319..dea287fde6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java @@ -98,7 +98,7 @@ import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaSpecialMultiCasings; public class LargeTurbineTextureHandler { @@ -206,7 +206,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[0]; } @@ -217,7 +217,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[3]; } @@ -228,7 +228,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[6]; } @@ -238,7 +238,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[1]; } @@ -248,7 +248,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[7]; } @@ -259,7 +259,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[8]; } @@ -270,7 +270,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[5]; } @@ -281,7 +281,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[2]; } @@ -295,7 +295,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[0]; } @@ -306,7 +306,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[3]; } @@ -317,7 +317,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[6]; } @@ -327,7 +327,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[1]; } @@ -337,7 +337,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[7]; } @@ -348,7 +348,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[8]; } @@ -359,7 +359,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[5]; } @@ -370,7 +370,7 @@ public class LargeTurbineTextureHandler { && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == side) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) - && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + && ((tMetaTileEntity instanceof MTEHatchTurbine))) { if (isUsingAnimatedTexture(tTileEntity)) { return mGetCurrentTextureSet_ACTIVE[2]; } @@ -388,8 +388,8 @@ public class LargeTurbineTextureHandler { aTile = (IGregTechTileEntity) tTileEntity; if (aTile != null) { final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); - if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { - aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity).getBaseMetaTileEntity() + if (aMetaTileEntity != null && aMetaTileEntity instanceof MTEHatchTurbine) { + aVal = ((MTEHatchTurbine) aMetaTileEntity).getBaseMetaTileEntity() .isActive(); // Logger.INFO("Returning "+aVal+" as Rotor Assembly controller status"); } @@ -398,11 +398,11 @@ public class LargeTurbineTextureHandler { return aVal; } - public static GT_MetaTileEntity_Hatch_Turbine isTurbineHatch(final IGregTechTileEntity aTileEntity) { + public static MTEHatchTurbine isTurbineHatch(final IGregTechTileEntity aTileEntity) { if (aTileEntity != null) { final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { - return (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; + if (aMetaTileEntity != null && aMetaTileEntity instanceof MTEHatchTurbine) { + return (MTEHatchTurbine) aMetaTileEntity; } } return null; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverOverflow.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverOverflow.java new file mode 100644 index 0000000000..f93b371aa3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverOverflow.java @@ -0,0 +1,198 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import java.util.concurrent.atomic.AtomicBoolean; + +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.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.gui.modularui.CoverUIBuildContext; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.GTUtility; +import gregtech.api.util.ISerializableObject; +import gregtech.common.gui.modularui.widget.CoverDataControllerWidget; +import gregtech.common.gui.modularui.widget.CoverDataFollowerNumericWidget; + +public class CoverOverflow extends CoverBehavior { + + public final int mTransferRate; + public final int mInitialTransferRate; + public final int mMaxTransferRate; + + public CoverOverflow(int aTransferRate) { + this.mTransferRate = aTransferRate * 1000 / 10; + this.mInitialTransferRate = aTransferRate; + this.mMaxTransferRate = aTransferRate * 1000; + } + + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if (aCoverVariable == 0) { + return aCoverVariable; + } + if ((aTileEntity instanceof IFluidHandler)) { + // Logger.INFO("Trying to Void via Overflow."); + IFluidHandler tTank1; + ForgeDirection directionFrom; + directionFrom = ForgeDirection.UNKNOWN; + tTank1 = (IFluidHandler) aTileEntity; + if (tTank1 != null) { + FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid; + if (aTankStack != null) { + // Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at + // "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside."); + if (aTankStack.amount > aCoverVariable) { + int aAmountToDrain = aTankStack.amount - aCoverVariable; + // Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like."); + if (aAmountToDrain > 0) { + FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true); + if (tLiquid != null) { + // Logger.INFO("Drained "+aAmountToDrain+"L."); + } + } + } + } else { + // Logger.INFO("Could not simulate drain on self."); + } + } + } + return aCoverVariable; + } + + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GTUtility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } else { + aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GTUtility.sendChatToPlayer( + aPlayer, + GTUtility.trans("322", "Overflow point: ") + aCoverVariable + GTUtility.trans("323", "L")); + return aCoverVariable; + } + + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + boolean aShift = aPlayer.isSneaking(); + int aAmount = aShift ? 128 : 8; + if (GTUtility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += aAmount; + } else { + aCoverVariable -= aAmount; + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GTUtility.sendChatToPlayer( + aPlayer, + GTUtility.trans("322", "Overflow point: ") + aCoverVariable + GTUtility.trans("323", "L")); + aTileEntity.setCoverDataAtSide(side, new ISerializableObject.LegacyCoverData(aCoverVariable)); + return true; + } + + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return false; + } + + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; + } + + // GUI + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public ModularWindow createWindow(CoverUIBuildContext buildContext) { + return new OverflowUIFactory(buildContext).createWindow(); + } + + private class OverflowUIFactory extends UIFactory { + + private static final int startX = 10; + private static final int startY = 25; + private static final int spaceX = 18; + private static final int spaceY = 18; + + public OverflowUIFactory(CoverUIBuildContext buildContext) { + super(buildContext); + } + + @SuppressWarnings("PointlessArithmeticExpression") + @Override + protected void addUIWidgets(ModularWindow.Builder builder) { + AtomicBoolean warn = new AtomicBoolean(false); + + builder + .widget( + new CoverDataControllerWidget<>(this::getCoverData, this::setCoverData, CoverOverflow.this) + .addFollower( + new CoverDataFollowerNumericWidget<>(), + coverData -> (double) convert(coverData), + (coverData, state) -> new ISerializableObject.LegacyCoverData(state.intValue()), + widget -> widget.setBounds(0, mMaxTransferRate) + .setScrollValues(1000, 144, 100000) + .setFocusOnGuiOpen(true) + .setPos(startX + spaceX * 0, startY + spaceY * 1 + 8) + .setSize(spaceX * 4 - 3, 12))) + .widget( + new TextWidget(GTUtility.trans("322", "Overflow point: ")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(startX, 4 + startY + spaceY * 0 + 8)); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverToggleVisual.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverToggleVisual.java new file mode 100644 index 0000000000..2ba532d11f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverToggleVisual.java @@ -0,0 +1,184 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.GTUtility; +import gregtech.api.util.ISerializableObject; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class CoverToggleVisual extends CoverBehavior { + + private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap<>(); + private static final Map sPrefixMap = new ConcurrentHashMap<>(); + private static final int VALUE_OFF = 0; + private static final int VALUE_ON = 1; + + public static String generateUniqueKey(ForgeDirection side, ICoverable aEntity) { + try { + BlockPos aPos = new BlockPos( + aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); + + String s = aEntity.getInventoryName() + "." + aPos.getUniqueIdentifier() + side.name(); + return s; + } catch (Throwable t) {} + XSTR x = new XSTR(); + return "ERROR." + x.getSeed() + x.hashCode() + x.nextDouble() + ".ID"; + } + + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + PlayerUtils + .messagePlayer(aPlayer, GTUtility.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); + return super.onCoverRightclick(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + return super.onCoverScrewdriverclick(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 1; + } + + @Override + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + try { + String aKey = generateUniqueKey(side, aTileEntity); + Integer b = sConnectionStateForEntityMap.get(aKey); + // Logger.INFO("Val: "+aCoverVariable); + if (b != null && aCoverVariable != b) { + aCoverVariable = b; + } + if (b == null) { + b = aCoverVariable; + sConnectionStateForEntityMap.put(aKey, b); + trySetState(side, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); + } + } catch (Throwable t) { + + } + return aCoverVariable; + } + + @Override + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return super.alwaysLookConnected(side, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { + if (!getConnectionState(aCoverVariable)) { + return 0; + } + return super.getRedstoneInput(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { + String aKey = generateUniqueKey(side, aTileEntity); + boolean state = getCoverConnections(aCover); + sPrefixMap.put(aKey, aCover.getUnlocalizedName()); + Logger.INFO("Mapping key " + aKey + " to " + state); + sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); + Logger.INFO("Key Value: " + (state ? VALUE_ON : VALUE_OFF)); + // Try set cover state directly + // trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); + super.placeCover(side, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + String aKey = generateUniqueKey(side, aTileEntity); + sConnectionStateForEntityMap.remove(aKey); + // Logger.INFO("Unmapping key "+aKey+"."); + return true; + } + + public static boolean getConnectionState(int aCoverVar) { + return aCoverVar == VALUE_ON; + } + + private static void trySetState(ForgeDirection side, int aState, ICoverable aTile) { + // Try set cover state directly + if (aTile instanceof IGregTechTileEntity gTileEntity) { + gTileEntity.setCoverDataAtSide(side, new ISerializableObject.LegacyCoverData(aState)); + } + } + + public static boolean getConnectionState(ForgeDirection side, ICoverable aTile) { + String aKey = generateUniqueKey(side, aTile); + return getConnectionState(aKey); + } + + public static boolean getConnectionState(String aKey) { + Integer b = sConnectionStateForEntityMap.get(aKey); + // Logger.INFO("Get State: "+b+" | "+aKey); + return b != null ? b == VALUE_ON : false; + } + + public static final boolean getCoverConnections(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getBoolean("AllowConnections"); + } + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java deleted file mode 100644 index a3341ea077..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java +++ /dev/null @@ -1,198 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.covers; - -import java.util.concurrent.atomic.AtomicBoolean; - -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.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.gui.modularui.GT_CoverUIBuildContext; -import gregtech.api.interfaces.tileentity.ICoverable; -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_NumericWidget; - -public class GTPP_Cover_Overflow extends GT_CoverBehavior { - - public final int mTransferRate; - public final int mInitialTransferRate; - public final int mMaxTransferRate; - - public GTPP_Cover_Overflow(int aTransferRate) { - this.mTransferRate = aTransferRate * 1000 / 10; - this.mInitialTransferRate = aTransferRate; - this.mMaxTransferRate = aTransferRate * 1000; - } - - public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, - ICoverable aTileEntity, long aTimer) { - if (aCoverVariable == 0) { - return aCoverVariable; - } - if ((aTileEntity instanceof IFluidHandler)) { - // Logger.INFO("Trying to Void via Overflow."); - IFluidHandler tTank1; - ForgeDirection directionFrom; - directionFrom = ForgeDirection.UNKNOWN; - tTank1 = (IFluidHandler) aTileEntity; - if (tTank1 != null) { - FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid; - if (aTankStack != null) { - // Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at - // "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside."); - if (aTankStack.amount > aCoverVariable) { - int aAmountToDrain = aTankStack.amount - aCoverVariable; - // Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like."); - if (aAmountToDrain > 0) { - FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true); - if (tLiquid != null) { - // Logger.INFO("Drained "+aAmountToDrain+"L."); - } - } - } - } else { - // Logger.INFO("Could not simulate drain on self."); - } - } - } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } else { - aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); - } - if (aCoverVariable > mMaxTransferRate) { - aCoverVariable = mInitialTransferRate; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxTransferRate; - } - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans("322", "Overflow point: ") + aCoverVariable + GT_Utility.trans("323", "L")); - return aCoverVariable; - } - - public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - boolean aShift = aPlayer.isSneaking(); - int aAmount = aShift ? 128 : 8; - if (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += aAmount; - } else { - aCoverVariable -= aAmount; - } - if (aCoverVariable > mMaxTransferRate) { - aCoverVariable = mInitialTransferRate; - } - if (aCoverVariable <= 0) { - aCoverVariable = mMaxTransferRate; - } - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans("322", "Overflow point: ") + aCoverVariable + GT_Utility.trans("323", "L")); - aTileEntity.setCoverDataAtSide(side, new ISerializableObject.LegacyCoverData(aCoverVariable)); - return true; - } - - public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, - ICoverable aTileEntity) { - return true; - } - - public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, - ICoverable aTileEntity) { - return true; - } - - public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return false; - } - - public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return true; - } - - public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return true; - } - - public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 5; - } - - // GUI - - @Override - public boolean hasCoverGUI() { - return true; - } - - @Override - public ModularWindow createWindow(GT_CoverUIBuildContext buildContext) { - return new OverflowUIFactory(buildContext).createWindow(); - } - - private class OverflowUIFactory extends UIFactory { - - private static final int startX = 10; - private static final int startY = 25; - private static final int spaceX = 18; - private static final int spaceY = 18; - - public OverflowUIFactory(GT_CoverUIBuildContext buildContext) { - super(buildContext); - } - - @SuppressWarnings("PointlessArithmeticExpression") - @Override - protected void addUIWidgets(ModularWindow.Builder builder) { - AtomicBoolean warn = new AtomicBoolean(false); - - builder - .widget( - new CoverDataControllerWidget<>(this::getCoverData, this::setCoverData, GTPP_Cover_Overflow.this) - .addFollower( - new CoverDataFollower_NumericWidget<>(), - coverData -> (double) convert(coverData), - (coverData, state) -> new ISerializableObject.LegacyCoverData(state.intValue()), - widget -> widget.setBounds(0, mMaxTransferRate) - .setScrollValues(1000, 144, 100000) - .setFocusOnGuiOpen(true) - .setPos(startX + spaceX * 0, startY + spaceY * 1 + 8) - .setSize(spaceX * 4 - 3, 12))) - .widget( - new TextWidget(GT_Utility.trans("322", "Overflow point: ")).setDefaultColor(COLOR_TEXT_GRAY.get()) - .setPos(startX, 4 + startY + spaceY * 0 + 8)); - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java deleted file mode 100644 index 42ab793c9c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java +++ /dev/null @@ -1,184 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.covers; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; - -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.XSTR; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.ISerializableObject; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - -public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { - - private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap<>(); - private static final Map sPrefixMap = new ConcurrentHashMap<>(); - private static final int VALUE_OFF = 0; - private static final int VALUE_ON = 1; - - public static String generateUniqueKey(ForgeDirection side, ICoverable aEntity) { - try { - BlockPos aPos = new BlockPos( - aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); - - String s = aEntity.getInventoryName() + "." + aPos.getUniqueIdentifier() + side.name(); - return s; - } catch (Throwable t) {} - XSTR x = new XSTR(); - return "ERROR." + x.getSeed() + x.hashCode() + x.nextDouble() + ".ID"; - } - - public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - PlayerUtils - .messagePlayer(aPlayer, GT_Utility.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); - return super.onCoverRightclick(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); - } - - public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - return super.onCoverScrewdriverclick(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); - } - - public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, - ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, - ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 1; - } - - @Override - public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, - ICoverable aTileEntity, long aTimer) { - try { - String aKey = generateUniqueKey(side, aTileEntity); - Integer b = sConnectionStateForEntityMap.get(aKey); - // Logger.INFO("Val: "+aCoverVariable); - if (b != null && aCoverVariable != b) { - aCoverVariable = b; - } - if (b == null) { - b = aCoverVariable; - sConnectionStateForEntityMap.put(aKey, b); - trySetState(side, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); - } - } catch (Throwable t) { - - } - return aCoverVariable; - } - - @Override - public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - @Override - public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aCoverVariable); - } - - @Override - public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return super.alwaysLookConnected(side, aCoverID, aCoverVariable, aTileEntity); - } - - @Override - public byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { - if (!getConnectionState(aCoverVariable)) { - return 0; - } - return super.getRedstoneInput(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); - } - - @Override - public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { - String aKey = generateUniqueKey(side, aTileEntity); - boolean state = getCoverConnections(aCover); - sPrefixMap.put(aKey, aCover.getUnlocalizedName()); - Logger.INFO("Mapping key " + aKey + " to " + state); - sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); - Logger.INFO("Key Value: " + (state ? VALUE_ON : VALUE_OFF)); - // Try set cover state directly - // trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); - super.placeCover(side, aCover, aTileEntity); - } - - @Override - public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - boolean aForced) { - String aKey = generateUniqueKey(side, aTileEntity); - sConnectionStateForEntityMap.remove(aKey); - // Logger.INFO("Unmapping key "+aKey+"."); - return true; - } - - public static boolean getConnectionState(int aCoverVar) { - return aCoverVar == VALUE_ON; - } - - private static void trySetState(ForgeDirection side, int aState, ICoverable aTile) { - // Try set cover state directly - if (aTile instanceof IGregTechTileEntity gTileEntity) { - gTileEntity.setCoverDataAtSide(side, new ISerializableObject.LegacyCoverData(aState)); - } - } - - public static boolean getConnectionState(ForgeDirection side, ICoverable aTile) { - String aKey = generateUniqueKey(side, aTile); - return getConnectionState(aKey); - } - - public static boolean getConnectionState(String aKey) { - Integer b = sConnectionStateForEntityMap.get(aKey); - // Logger.INFO("Get State: "+b+" | "+aKey); - return b != null ? b == VALUE_ON : false; - } - - public static final boolean getCoverConnections(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("CustomCoverMeta"); - if (aNBT != null) { - return aNBT.getBoolean("AllowConnections"); - } - } - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 924484e098..e11f4fae02 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import static gregtech.api.GregTech_API.mEUtoRF; +import static gregtech.api.GregTechAPI.mEUtoRF; import static gregtech.api.enums.Mods.Baubles; import static gregtech.api.enums.Mods.COFHCore; @@ -20,26 +20,26 @@ import cofh.api.energy.IEnergyContainerItem; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_ModHandler; -import gregtech.common.items.GT_MetaGenerated_Item_01; -import gregtech.common.items.GT_MetaGenerated_Item_02; -import gregtech.common.items.GT_MetaGenerated_Item_03; -import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.api.enums.GTValues; +import gregtech.api.util.GTModHandler; +import gregtech.common.items.MetaGeneratedItem01; +import gregtech.common.items.MetaGeneratedItem02; +import gregtech.common.items.MetaGeneratedItem03; +import gregtech.common.items.MetaGeneratedTool01; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.MTEWirelessCharger; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; public class ChargingHelper { - private static final Map> mValidPlayers = new HashMap<>(); - protected static Map mChargerMap = new HashMap<>(); + private static final Map> mValidPlayers = new HashMap<>(); + protected static Map mChargerMap = new HashMap<>(); private int mTickTimer = 0; private static final int mTickMultiplier = 20; @@ -75,7 +75,7 @@ public class ChargingHelper { } } - for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()) { + for (MTEWirelessCharger mEntityTemp : mChargerMap.values()) { if (mEntityTemp != null) { if (mEntityTemp.getBaseMetaTileEntity() == null || !mEntityTemp.getBaseMetaTileEntity() .isAllowedToWork()) continue; @@ -96,11 +96,11 @@ public class ChargingHelper { if (mStartingEu - mEntityTemp.getEUVar() <= 0) { long mMaxDistance; if (mEntityTemp.getMode() == 0) { - mMaxDistance = (4 * GT_Values.V[mEntityTemp.getTier()]); + mMaxDistance = (4 * GTValues.V[mEntityTemp.getTier()]); } else if (mEntityTemp.getMode() == 1) { mMaxDistance = (mEntityTemp.getTier() * 10L); } else { - mMaxDistance = (4 * GT_Values.V[mEntityTemp.getTier()] / 2); + mMaxDistance = (4 * GTValues.V[mEntityTemp.getTier()] / 2); } double mDistance = calculateDistance(mEntityTemp, mPlayerMan); long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); @@ -121,7 +121,7 @@ public class ChargingHelper { } catch (Throwable t) { if (!mChargerMap.isEmpty()) { for (BlockPos aPos : mChargerMap.keySet()) { - GregtechMetaWirelessCharger r = mChargerMap.get(aPos); + MTEWirelessCharger r = mChargerMap.get(aPos); if (r == null || r.getBaseMetaTileEntity() .isInvalidTileEntity()) { mChargerMap.remove(aPos); @@ -131,11 +131,11 @@ public class ChargingHelper { } } - public static GregtechMetaWirelessCharger getEntry(BlockPos mPos) { + public static MTEWirelessCharger getEntry(BlockPos mPos) { return mChargerMap.get(mPos); } - public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) { + public static boolean addEntry(BlockPos mPos, MTEWirelessCharger mEntity) { if (mEntity == null) { return false; } @@ -143,7 +143,7 @@ public class ChargingHelper { return true; } - public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) { + public static boolean removeEntry(BlockPos mPos, MTEWirelessCharger mEntity) { if (mEntity == null) { return false; } @@ -154,31 +154,31 @@ public class ChargingHelper { } } - public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity) { + public static boolean addValidPlayer(EntityPlayer mPlayer, MTEWirelessCharger mEntity) { if (mEntity == null) { return false; } if (mValidPlayers.containsKey(mPlayer.getDisplayName())) { return false; } else { - Pair mEntry = new Pair<>(mEntity, (byte) mEntity.getMode()); + Pair mEntry = new Pair<>(mEntity, (byte) mEntity.getMode()); return mValidPlayers.put(mPlayer.getDisplayName(), mEntry) == null; } } - public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity) { + public static boolean removeValidPlayer(EntityPlayer mPlayer, MTEWirelessCharger mEntity) { if (mEntity == null) { return false; } if (mValidPlayers.containsKey(mPlayer.getDisplayName())) { - Pair mEntry = new Pair<>(mEntity, (byte) mEntity.getMode()); + Pair mEntry = new Pair<>(mEntity, (byte) mEntity.getMode()); return mValidPlayers.remove(mPlayer.getDisplayName(), mEntry); } else { return false; } } - private boolean canCharge(GregtechMetaWirelessCharger charger, EntityPlayer chargeablePlayer, + private boolean canCharge(MTEWirelessCharger charger, EntityPlayer chargeablePlayer, Map longRangeChargers, Map shortRangeChargers) { if (charger.getMode() == 0) { return !longRangeChargers.isEmpty() && longRangeChargers.containsKey(chargeablePlayer.getDisplayName()); @@ -192,7 +192,7 @@ public class ChargingHelper { } } - private double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, EntityPlayer mPlayerMan) { + private double calculateDistance(MTEWirelessCharger mEntityTemp, EntityPlayer mPlayerMan) { if (mEntityTemp == null || mPlayerMan == null) { return 0; } @@ -201,14 +201,14 @@ public class ChargingHelper { mEntityTemp.getPositionOfEntity(mPlayerMan)); } - private void chargeItems(@Nonnull GregtechMetaWirelessCharger mEntity, ItemStack[] mItems) { + private void chargeItems(@Nonnull MTEWirelessCharger mEntity, ItemStack[] mItems) { if (mItems == null || mItems.length == 0) { return; } chargeItemsEx(mEntity, mItems); } - private void chargeItemsEx(@Nonnull GregtechMetaWirelessCharger mEntity, ItemStack[] mItems) { + private void chargeItemsEx(@Nonnull MTEWirelessCharger mEntity, ItemStack[] mItems) { // Bad Inventory if (mItems == null || mItems.length == 0) { return; @@ -234,19 +234,18 @@ public class ChargingHelper { } // Try to get charge direct from NBT for GT and IC2 stacks - if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 - || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 - || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || mTemp.getItem() instanceof GT_MetaGenerated_Item_03 + if (mTemp.getItem() instanceof MetaGeneratedTool01 || mTemp.getItem() instanceof MetaGeneratedItem01 + || mTemp.getItem() instanceof MetaGeneratedItem02 + || mTemp.getItem() instanceof MetaGeneratedItem03 || mTemp.getItem() .getClass() .getName() - .equalsIgnoreCase(GT_MetaGenerated_Tool_01.class.getName())) { + .equalsIgnoreCase(MetaGeneratedTool01.class.getName())) { if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")) { if (!mTemp.getDisplayName() .toLowerCase() .contains("battery")) { - if (!GT_ModHandler.isElectricItem(mTemp)) { + if (!GTModHandler.isElectricItem(mTemp)) { continue; } } else { @@ -284,8 +283,7 @@ public class ChargingHelper { int mMultiVoltage = (int) (mMulti * mVoltageIncrease); if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge) { - if (GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, Integer.MAX_VALUE, true, false) - > 0) { + if (GTModHandler.chargeElectricItem(mTemp, mMultiVoltage, Integer.MAX_VALUE, true, false) > 0) { for (int i = 0; i < mMulti; i++) { ElectricItem.manager.charge(mTemp, mVoltageIncrease, Integer.MAX_VALUE, false, false); } @@ -300,7 +298,7 @@ public class ChargingHelper { mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); if (mitemCurrentCharge < mItemMaxCharge && mitemCurrentCharge >= (mItemMaxCharge - mVoltage)) { int xDif = (int) (mItemMaxCharge - mitemCurrentCharge); - if (GT_ModHandler.chargeElectricItem(mTemp, xDif, Integer.MAX_VALUE, true, false) >= 0) { + if (GTModHandler.chargeElectricItem(mTemp, xDif, Integer.MAX_VALUE, true, false) >= 0) { if (ElectricItem.manager.getCharge(mTemp) >= mItemMaxCharge) { mEntity.setEUVar(mEntity.getEUVar() - (xDif)); mEuStored = mEntity.getEUVar(); @@ -334,7 +332,7 @@ public class ChargingHelper { if (itemstack == null) { return false; } - if (GT_ModHandler.isElectricItem(itemstack)) { + if (GTModHandler.isElectricItem(itemstack)) { return true; } return itemstack.getItem() instanceof IElectricItem; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java index 8cbb473a42..773bf0127e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java @@ -6,8 +6,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.Material; @@ -31,14 +31,14 @@ public class FlotationRecipeHandler { public static Material getMaterialOfMilledProduct(ItemStack aMilled) { for (String aKey : sMilledMap.keySet()) { ItemStack aTempMilledStack = sMilledMap.get(aKey); - if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) { + if (GTUtility.areStacksEqual(aTempMilledStack, aMilled, true)) { return sMaterialMap.get(aKey); } } return null; } - public static ItemStack findMilledStack(GT_Recipe aRecipe) { + public static ItemStack findMilledStack(GTRecipe aRecipe) { if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) { return null; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GTMethodHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GTMethodHelper.java new file mode 100644 index 0000000000..357764c820 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GTMethodHelper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; + +public class GTMethodHelper { + + public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, ForgeDirection side) { + if (tTileEntity instanceof ITexturedTileEntity) { + return ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, side); + } + return BlockIcons.ERROR_RENDERING; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java deleted file mode 100644 index ced9b46c3e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java +++ /dev/null @@ -1,19 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.helpers; - -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.ITexturedTileEntity; - -public class GT_MethodHelper { - - public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, ForgeDirection side) { - if (tTileEntity instanceof ITexturedTileEntity) { - return ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, side); - } - return BlockIcons.ERROR_RENDERING; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index 2b0e2a7a4d..57a985f3f3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -6,7 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import gregtech.api.enums.ItemList; -import gregtech.common.items.GT_VolumetricFlask; +import gregtech.common.items.ItemVolumetricFlask; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; public class VolumetricFlaskHelper { @@ -42,8 +42,8 @@ public class VolumetricFlaskHelper { public static int getMaxFlaskCapacity(ItemStack aStack) { if (aStack != null) { Item aItem = aStack.getItem(); - if (aItem instanceof GT_VolumetricFlask) { - return ((GT_VolumetricFlask) aItem).getMaxCapacity(); + if (aItem instanceof ItemVolumetricFlask) { + return ((ItemVolumetricFlask) aItem).getMaxCapacity(); } } return 0; @@ -120,6 +120,6 @@ public class VolumetricFlaskHelper { } public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { - return new GT_VolumetricFlask(unlocalized, english, maxCapacity); + return new ItemVolumetricFlask(unlocalized, english, maxCapacity); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java index 3717f17554..03a4ace32f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java @@ -1,7 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.helpers.tesseract; -import static gtPlusPlus.core.lib.CORE.sTesseractGeneratorOwnershipMap; -import static gtPlusPlus.core.lib.CORE.sTesseractTerminalOwnershipMap; +import static gtPlusPlus.core.lib.GTPPCore.sTesseractGeneratorOwnershipMap; +import static gtPlusPlus.core.lib.GTPPCore.sTesseractTerminalOwnershipMap; import java.util.HashMap; import java.util.Map; @@ -12,8 +12,8 @@ import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.MTETesseractGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.MTETesseractTerminal; public class TesseractHelper { @@ -25,8 +25,7 @@ public class TesseractHelper { */ // Checks if a Generator is owned by a player. - public static final boolean isGeneratorOwnedByPlayer(EntityPlayer player, - GT_MetaTileEntity_TesseractGenerator generator) { + public static final boolean isGeneratorOwnedByPlayer(EntityPlayer player, MTETesseractGenerator generator) { if (player == null) { Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); return false; @@ -35,9 +34,9 @@ public class TesseractHelper { UUID playerIdentifier = player.getUniqueID(); if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 2"); - Map generators = getGeneratorOwnershipByPlayer(player); - Set> players = generators.entrySet(); - for (Entry current : players) { + Map generators = getGeneratorOwnershipByPlayer(player); + Set> players = generators.entrySet(); + for (Entry current : players) { // Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 3"); if (current.getValue() .equals(generator)) { @@ -52,23 +51,22 @@ public class TesseractHelper { // Saves A Generator to the Players UUID map along with the Freq. public static final boolean setGeneratorOwnershipByPlayer(EntityPlayer player, int freq, - GT_MetaTileEntity_TesseractGenerator generator) { + MTETesseractGenerator generator) { if (player == null) { return false; } UUID playerIdentifier = player.getUniqueID(); Logger.WARNING("Setting Generator on " + freq + " for " + player.getDisplayName() + "."); if (playerIdentifier != null) { - Map playerOwned = sTesseractGeneratorOwnershipMap - .get(playerIdentifier); + Map playerOwned = sTesseractGeneratorOwnershipMap.get(playerIdentifier); if (playerOwned == null || playerOwned.isEmpty()) { - Map newOwnershipMap = new HashMap<>(); + Map newOwnershipMap = new HashMap<>(); newOwnershipMap.put(freq, generator); sTesseractGeneratorOwnershipMap.put(playerIdentifier, newOwnershipMap); Logger.WARNING("Success! [Empty Map]"); return true; } else if (sTesseractGeneratorOwnershipMap.containsKey(playerIdentifier)) { - Map ownershipMap = sTesseractGeneratorOwnershipMap + Map ownershipMap = sTesseractGeneratorOwnershipMap .get(playerIdentifier); if (!ownershipMap.containsKey(freq)) { ownershipMap.put(freq, generator); @@ -84,7 +82,7 @@ public class TesseractHelper { } // Gets Generator based on Frequency. - public static final GT_MetaTileEntity_TesseractGenerator getGeneratorByFrequency(EntityPlayer player, int freq) { + public static final MTETesseractGenerator getGeneratorByFrequency(EntityPlayer player, int freq) { if (player == null) { return null; } @@ -92,9 +90,9 @@ public class TesseractHelper { Logger.WARNING("Getting Generator on " + freq + " for " + player.getDisplayName() + "."); if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { // Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 1"); - Map generators = getGeneratorOwnershipByPlayer(player); - Set> players = generators.entrySet(); - for (Entry current : players) { + Map generators = getGeneratorOwnershipByPlayer(player); + Set> players = generators.entrySet(); + for (Entry current : players) { // Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 2"); if (current.getKey() .equals(freq)) { @@ -131,16 +129,15 @@ public class TesseractHelper { */ // Checks if a Terminal is owned by a player. - public static final boolean isTerminalOwnedByPlayer(EntityPlayer player, - GT_MetaTileEntity_TesseractTerminal generator) { + public static final boolean isTerminalOwnedByPlayer(EntityPlayer player, MTETesseractTerminal generator) { if (player == null) { return false; } UUID playerIdentifier = player.getUniqueID(); if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Map generators = getTerminalOwnershipByPlayer(player); - Set> players = generators.entrySet(); - for (Entry current : players) { + Map generators = getTerminalOwnershipByPlayer(player); + Set> players = generators.entrySet(); + for (Entry current : players) { if (current.getValue() .equals(generator)) { return true; @@ -152,24 +149,22 @@ public class TesseractHelper { // Saves A Terminal to the Players UUID map along with the Freq. public static final boolean setTerminalOwnershipByPlayer(EntityPlayer player, int freq, - GT_MetaTileEntity_TesseractTerminal generator) { + MTETesseractTerminal generator) { if (player == null) { return false; } UUID playerIdentifier = player.getUniqueID(); if (playerIdentifier != null) { Logger.WARNING("Setting Terminal on " + freq + " for " + player.getDisplayName() + "."); - Map playerOwned = sTesseractTerminalOwnershipMap - .get(playerIdentifier); + Map playerOwned = sTesseractTerminalOwnershipMap.get(playerIdentifier); if (playerOwned == null || playerOwned.isEmpty()) { - Map newOwnershipMap = new HashMap<>(); + Map newOwnershipMap = new HashMap<>(); newOwnershipMap.put(freq, generator); sTesseractTerminalOwnershipMap.put(playerIdentifier, newOwnershipMap); Logger.WARNING("Success! [Empty Map]"); return true; } else if (sTesseractTerminalOwnershipMap.containsKey(playerIdentifier)) { - Map ownershipMap = sTesseractTerminalOwnershipMap - .get(playerIdentifier); + Map ownershipMap = sTesseractTerminalOwnershipMap.get(playerIdentifier); if (!ownershipMap.containsKey(freq)) { ownershipMap.put(freq, generator); } @@ -183,16 +178,16 @@ public class TesseractHelper { } // Gets Terminal based on Frequency. - public static final GT_MetaTileEntity_TesseractTerminal getTerminalByFrequency(EntityPlayer player, int freq) { + public static final MTETesseractTerminal getTerminalByFrequency(EntityPlayer player, int freq) { if (player == null) { return null; } UUID playerIdentifier = player.getUniqueID(); Logger.WARNING("Getting Terminal on " + freq + " for " + player.getDisplayName() + "."); if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Map generators = getTerminalOwnershipByPlayer(player); - Set> players = generators.entrySet(); - for (Entry current : players) { + Map generators = getTerminalOwnershipByPlayer(player); + Set> players = generators.entrySet(); + for (Entry current : players) { if (current.getKey() .equals(freq)) { Logger.WARNING("Success!"); @@ -223,13 +218,11 @@ public class TesseractHelper { * Internal Methods * */ - private static Map getGeneratorOwnershipByPlayer( - EntityPlayer player) { + private static Map getGeneratorOwnershipByPlayer(EntityPlayer player) { UUID playerIdentifier = player.getUniqueID(); if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { - Set>> players = sTesseractGeneratorOwnershipMap - .entrySet(); - for (Entry> current : players) { + Set>> players = sTesseractGeneratorOwnershipMap.entrySet(); + for (Entry> current : players) { if (current.getKey() .compareTo(playerIdentifier) == 0) { return current.getValue(); @@ -239,12 +232,11 @@ public class TesseractHelper { return null; } - private static Map getTerminalOwnershipByPlayer(EntityPlayer player) { + private static Map getTerminalOwnershipByPlayer(EntityPlayer player) { UUID playerIdentifier = player.getUniqueID(); if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { - Set>> players = sTesseractTerminalOwnershipMap - .entrySet(); - for (Entry> current : players) { + Set>> players = sTesseractTerminalOwnershipMap.entrySet(); + for (Entry> current : players) { if (current.getKey() .compareTo(playerIdentifier) == 0) { return current.getValue(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/Ids_MetaGeneratedGregtechItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/Ids_MetaGeneratedGregtechItems.java deleted file mode 100644 index 5a9e9db772..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/Ids_MetaGeneratedGregtechItems.java +++ /dev/null @@ -1,47 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.items; - -public enum Ids_MetaGeneratedGregtechItems { - - Shape_Extruder_WindmillShaft(40), - Pellet_RTG_PU238(41), - Pellet_RTG_SR90(42), - Pellet_RTG_PO210(43), - Pellet_RTG_AM241(44), - Battery_RE_EV_Sodium(50), - Battery_RE_EV_Cadmium(52), - Battery_RE_EV_Lithium(54), - Gregtech_Computer_Cube(55), - Battery_Gem_1(66), - Battery_Gem_2(68), - Battery_Gem_3(70), - Cover_Overflow_LV(72), - Cover_Overflow_MV(73), - Cover_Overflow_HV(74), - Cover_Overflow_EV(75), - Cover_Overflow_IV(76), - Compressed_Fusion_Reactor(100), - Laser_Lens_Special(105), - Battery_Casing_Gem_1(106), - Battery_Casing_Gem_2(107), - Battery_Casing_Gem_3(108), - Battery_Casing_Gem_4(109), - Battery_Gem_4(110), - Laser_Lens_WoodsGlass(140), - TransmissionComponent_LV(142), - TransmissionComponent_MV(143), - TransmissionComponent_HV(144), - TransmissionComponent_EV(145), - TransmissionComponent_IV(146), - TransmissionComponent_LuV(147), - TransmissionComponent_ZPM(148), - TransmissionComponent_UV(149), - TransmissionComponent_UHV(150), - Distillus_Upgrade_Chip(151), - Maceration_Upgrade_Chip(152); - - public final int ID; - - Ids_MetaGeneratedGregtechItems(int ID) { - this.ID = ID; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java index 8edb8c2cf9..a6cd63ca19 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java @@ -16,17 +16,17 @@ import net.minecraft.world.World; import org.apache.commons.lang3.StringUtils; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTech_API; +import gregtech.api.GregTechAPI; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_MultiTexture; -import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.GTMultiTexture; +import gregtech.api.objects.GTRenderedTexture; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; +import gtPlusPlus.xmod.gregtech.common.covers.CoverToggleVisual; public class MetaCustomCoverItem extends Item { @@ -72,10 +72,10 @@ public class MetaCustomCoverItem extends Item { if (i > 0 && hide()) { ItemUtils.hideItemFromNEI(thisStack); } - GregTech_API.registerCover( + GregTechAPI.registerCover( thisStack, - new GT_MultiTexture(new ITexture[] { new GT_RenderedTexture(mTextures[i]) }), - new GTPP_Cover_ToggleVisual()); + new GTMultiTexture(new ITexture[] { new GTRenderedTexture(mTextures[i]) }), + new CoverToggleVisual()); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index ec9416be02..a787e4c4ce 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -1,64 +1,64 @@ package gtPlusPlus.xmod.gregtech.common.items; -import static gregtech.api.util.GT_RecipeConstants.RTG_DURATION_IN_DAYS; -import static gregtech.client.GT_TooltipHandler.Tier.EV; -import static gregtech.client.GT_TooltipHandler.registerTieredTooltip; +import static gregtech.api.util.GTRecipeConstants.RTG_DURATION_IN_DAYS; +import static gregtech.client.GTTooltipHandler.Tier.EV; +import static gregtech.client.GTTooltipHandler.registerTieredTooltip; import static gtPlusPlus.api.recipe.GTPPRecipeMaps.rtgFuels; import static gtPlusPlus.core.util.Utils.getTcAspectStack; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Casing_Gem_1; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Casing_Gem_2; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Casing_Gem_3; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Casing_Gem_4; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Gem_1; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Gem_2; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Gem_3; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_Gem_4; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_RE_EV_Cadmium; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_RE_EV_Lithium; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Battery_RE_EV_Sodium; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Compressed_Fusion_Reactor; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Cover_Overflow_EV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Cover_Overflow_HV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Cover_Overflow_IV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Cover_Overflow_LV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Cover_Overflow_MV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Distillus_Upgrade_Chip; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Gregtech_Computer_Cube; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Laser_Lens_Special; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Laser_Lens_WoodsGlass; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Maceration_Upgrade_Chip; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Pellet_RTG_AM241; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Pellet_RTG_PO210; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Pellet_RTG_PU238; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Pellet_RTG_SR90; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.Shape_Extruder_WindmillShaft; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_EV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_HV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_IV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_LV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_LuV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_MV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_UHV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_UV; -import static gtPlusPlus.xmod.gregtech.common.items.Ids_MetaGeneratedGregtechItems.TransmissionComponent_ZPM; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Casing_Gem_1; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Casing_Gem_2; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Casing_Gem_3; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Casing_Gem_4; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Gem_1; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Gem_2; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Gem_3; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_Gem_4; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_RE_EV_Cadmium; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_RE_EV_Lithium; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Battery_RE_EV_Sodium; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Compressed_Fusion_Reactor; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Cover_Overflow_EV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Cover_Overflow_HV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Cover_Overflow_IV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Cover_Overflow_LV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Cover_Overflow_MV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Distillus_Upgrade_Chip; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Gregtech_Computer_Cube; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Laser_Lens_Special; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Laser_Lens_WoodsGlass; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Maceration_Upgrade_Chip; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Pellet_RTG_AM241; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Pellet_RTG_PO210; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Pellet_RTG_PU238; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Pellet_RTG_SR90; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.Shape_Extruder_WindmillShaft; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_EV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_HV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_IV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_LV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_LuV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_MV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_UHV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_UV; +import static gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedItemIDs.TransmissionComponent_ZPM; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.TCAspects; import gregtech.api.enums.Textures; import gregtech.api.enums.TierEU; -import gregtech.api.objects.GT_MultiTexture; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; +import gregtech.api.objects.GTMultiTexture; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTModHandler; import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_X32; +import gtPlusPlus.xmod.gregtech.api.items.GTMetaItemX32; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow; +import gtPlusPlus.xmod.gregtech.common.covers.CoverOverflow; -public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { +public class MetaGeneratedGregtechItems extends GTMetaItemX32 { public static final MetaGeneratedGregtechItems INSTANCE; @@ -85,27 +85,27 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { Battery_RE_EV_Sodium.ID, "Quad Cell Sodium Battery", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 2L), - getTcAspectStack(TC_Aspects.METALLUM, 2L), - getTcAspectStack(TC_Aspects.POTENTIA, 2L))); + getTcAspectStack(TCAspects.ELECTRUM, 2L), + getTcAspectStack(TCAspects.METALLUM, 2L), + getTcAspectStack(TCAspects.POTENTIA, 2L))); GregtechItemList.Battery_RE_EV_Cadmium.set( this.addItem( Battery_RE_EV_Cadmium.ID, "Quad Cell Cadmium Battery", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.METALLUM, 1L), - getTcAspectStack(TC_Aspects.POTENTIA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.METALLUM, 1L), + getTcAspectStack(TCAspects.POTENTIA, 1L))); GregtechItemList.Battery_RE_EV_Lithium.set( this.addItem( Battery_RE_EV_Lithium.ID, "Quad Cell Lithium Battery", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 3L), - getTcAspectStack(TC_Aspects.METALLUM, 3L), - getTcAspectStack(TC_Aspects.POTENTIA, 3L))); + getTcAspectStack(TCAspects.ELECTRUM, 3L), + getTcAspectStack(TCAspects.METALLUM, 3L), + getTcAspectStack(TCAspects.POTENTIA, 3L))); /** * Power Gems @@ -115,27 +115,27 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { Battery_Gem_1.ID, "Proton Cell", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 8L), - getTcAspectStack(TC_Aspects.METALLUM, 24L), - getTcAspectStack(TC_Aspects.POTENTIA, 16L))); + getTcAspectStack(TCAspects.ELECTRUM, 8L), + getTcAspectStack(TCAspects.METALLUM, 24L), + getTcAspectStack(TCAspects.POTENTIA, 16L))); GregtechItemList.Battery_Gem_2.set( this.addItem( Battery_Gem_2.ID, "Electron Cell", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 16L), - getTcAspectStack(TC_Aspects.METALLUM, 32L), - getTcAspectStack(TC_Aspects.POTENTIA, 32L))); + getTcAspectStack(TCAspects.ELECTRUM, 16L), + getTcAspectStack(TCAspects.METALLUM, 32L), + getTcAspectStack(TCAspects.POTENTIA, 32L))); GregtechItemList.Battery_Gem_3.set( this.addItem( Battery_Gem_3.ID, "Quark Entanglement", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 32L), - getTcAspectStack(TC_Aspects.METALLUM, 48L), - getTcAspectStack(TC_Aspects.POTENTIA, 64L))); + getTcAspectStack(TCAspects.ELECTRUM, 32L), + getTcAspectStack(TCAspects.METALLUM, 48L), + getTcAspectStack(TCAspects.POTENTIA, 64L))); // RTG Pellet GregtechItemList.Pellet_RTG_PU238.set( @@ -143,36 +143,36 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { Pellet_RTG_PU238.ID, StringUtils.superscript("238") + "Pu Pellet", "", - getTcAspectStack(TC_Aspects.RADIO, 4L), - getTcAspectStack(TC_Aspects.POTENTIA, 2L), - getTcAspectStack(TC_Aspects.METALLUM, 2L))); + getTcAspectStack(TCAspects.RADIO, 4L), + getTcAspectStack(TCAspects.POTENTIA, 2L), + getTcAspectStack(TCAspects.METALLUM, 2L))); GregtechItemList.Pellet_RTG_SR90.set( this.addItem( Pellet_RTG_SR90.ID, StringUtils.superscript("90") + "Sr Pellet", "", - getTcAspectStack(TC_Aspects.RADIO, 4L), - getTcAspectStack(TC_Aspects.POTENTIA, 2L), - getTcAspectStack(TC_Aspects.METALLUM, 2L))); + getTcAspectStack(TCAspects.RADIO, 4L), + getTcAspectStack(TCAspects.POTENTIA, 2L), + getTcAspectStack(TCAspects.METALLUM, 2L))); GregtechItemList.Pellet_RTG_PO210.set( this.addItem( Pellet_RTG_PO210.ID, StringUtils.superscript("210") + "Po Pellet", "", - getTcAspectStack(TC_Aspects.RADIO, 4L), - getTcAspectStack(TC_Aspects.POTENTIA, 2L), - getTcAspectStack(TC_Aspects.METALLUM, 2L))); + getTcAspectStack(TCAspects.RADIO, 4L), + getTcAspectStack(TCAspects.POTENTIA, 2L), + getTcAspectStack(TCAspects.METALLUM, 2L))); GregtechItemList.Pellet_RTG_AM241.set( this.addItem( Pellet_RTG_AM241.ID, StringUtils.superscript("241") + "Am Pellet", "", - getTcAspectStack(TC_Aspects.RADIO, 4L), - getTcAspectStack(TC_Aspects.POTENTIA, 2L), - getTcAspectStack(TC_Aspects.METALLUM, 2L))); + getTcAspectStack(TCAspects.RADIO, 4L), + getTcAspectStack(TCAspects.POTENTIA, 2L), + getTcAspectStack(TCAspects.METALLUM, 2L))); // Computer Cube GregtechItemList.Gregtech_Computer_Cube.set( @@ -180,59 +180,59 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { Gregtech_Computer_Cube.ID, "Gregtech Computer Cube", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 8L), - getTcAspectStack(TC_Aspects.METALLUM, 8L), - getTcAspectStack(TC_Aspects.POTENTIA, 8L))); + getTcAspectStack(TCAspects.ELECTRUM, 8L), + getTcAspectStack(TCAspects.METALLUM, 8L), + getTcAspectStack(TCAspects.POTENTIA, 8L))); GregtechItemList.Cover_Overflow_LV.set( this.addItem( Cover_Overflow_LV.ID, "Overflow Valve (LV)", "Maximum void amount: 64,000", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.MACHINA, 1L), - getTcAspectStack(TC_Aspects.ITER, 1L), - getTcAspectStack(TC_Aspects.AQUA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.MACHINA, 1L), + getTcAspectStack(TCAspects.ITER, 1L), + getTcAspectStack(TCAspects.AQUA, 1L))); GregtechItemList.Cover_Overflow_MV.set( this.addItem( Cover_Overflow_MV.ID, "Overflow Valve (MV)", "Maximum void amount: 512,000", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.MACHINA, 1L), - getTcAspectStack(TC_Aspects.ITER, 1L), - getTcAspectStack(TC_Aspects.AQUA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.MACHINA, 1L), + getTcAspectStack(TCAspects.ITER, 1L), + getTcAspectStack(TCAspects.AQUA, 1L))); GregtechItemList.Cover_Overflow_HV.set( this.addItem( Cover_Overflow_HV.ID, "Overflow Valve (HV)", "Maximum void amount: 4,096,000", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.MACHINA, 1L), - getTcAspectStack(TC_Aspects.ITER, 1L), - getTcAspectStack(TC_Aspects.AQUA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.MACHINA, 1L), + getTcAspectStack(TCAspects.ITER, 1L), + getTcAspectStack(TCAspects.AQUA, 1L))); GregtechItemList.Cover_Overflow_EV.set( this.addItem( Cover_Overflow_EV.ID, "Overflow Valve (EV)", "Maximum void amount: 32,768,000", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.MACHINA, 1L), - getTcAspectStack(TC_Aspects.ITER, 1L), - getTcAspectStack(TC_Aspects.AQUA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.MACHINA, 1L), + getTcAspectStack(TCAspects.ITER, 1L), + getTcAspectStack(TCAspects.AQUA, 1L))); GregtechItemList.Cover_Overflow_IV.set( this.addItem( Cover_Overflow_IV.ID, "Overflow Valve (IV)", "Maximum void amount: 262,144,000", - getTcAspectStack(TC_Aspects.ELECTRUM, 1L), - getTcAspectStack(TC_Aspects.MACHINA, 1L), - getTcAspectStack(TC_Aspects.ITER, 1L), - getTcAspectStack(TC_Aspects.AQUA, 1L))); + getTcAspectStack(TCAspects.ELECTRUM, 1L), + getTcAspectStack(TCAspects.MACHINA, 1L), + getTcAspectStack(TCAspects.ITER, 1L), + getTcAspectStack(TCAspects.AQUA, 1L))); // Fusion Reactor MK4 Singularity GregtechItemList.Compressed_Fusion_Reactor.set( @@ -258,9 +258,9 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { Battery_Gem_4.ID, "Graviton Anomaly", "Reusable", - getTcAspectStack(TC_Aspects.ELECTRUM, 64L), - getTcAspectStack(TC_Aspects.METALLUM, 64L), - getTcAspectStack(TC_Aspects.POTENTIA, 64L))); + getTcAspectStack(TCAspects.ELECTRUM, 64L), + getTcAspectStack(TCAspects.METALLUM, 64L), + getTcAspectStack(TCAspects.POTENTIA, 64L))); /* * High Tier 'Saws' for the tree Farm @@ -285,11 +285,11 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { aTransParts[tier - 1].set( this.addItem( IDs[tier - 1], - "Transmission Component (" + GT_Values.VN[tier] + ")", + "Transmission Component (" + GTValues.VN[tier] + ")", "", - getTcAspectStack(TC_Aspects.ELECTRUM, tier), - getTcAspectStack(TC_Aspects.MACHINA, tier), - getTcAspectStack(TC_Aspects.MAGNETO, tier))); + getTcAspectStack(TCAspects.ELECTRUM, tier), + getTcAspectStack(TCAspects.MACHINA, tier), + getTcAspectStack(TCAspects.MAGNETO, tier))); } // Distillus Chip @@ -308,17 +308,17 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { } private void setAllElectricStats() { - this.setElectricStats(32000 + Battery_RE_EV_Cadmium.ID, 4800000L, GT_Values.V[4], 4L, -3L, true); - this.setElectricStats(32000 + Battery_RE_EV_Sodium.ID, 3200000L, GT_Values.V[4], 4L, -3L, true); - this.setElectricStats(32000 + Battery_RE_EV_Lithium.ID, 6400000L, GT_Values.V[4], 4L, -3L, true); - this.setElectricStats(32000 + Battery_Gem_1.ID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); - this.setElectricStats(32000 + Battery_Gem_2.ID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); - this.setElectricStats(32000 + Battery_Gem_3.ID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); - this.setElectricStats(32000 + Battery_Casing_Gem_4.ID, (64000000000L * 16), GT_Values.V[9], 9L, -3L, false); + this.setElectricStats(32000 + Battery_RE_EV_Cadmium.ID, 4800000L, GTValues.V[4], 4L, -3L, true); + this.setElectricStats(32000 + Battery_RE_EV_Sodium.ID, 3200000L, GTValues.V[4], 4L, -3L, true); + this.setElectricStats(32000 + Battery_RE_EV_Lithium.ID, 6400000L, GTValues.V[4], 4L, -3L, true); + this.setElectricStats(32000 + Battery_Gem_1.ID, GTValues.V[6] * 20 * 300 / 4, GTValues.V[6], 6L, -3L, false); + this.setElectricStats(32000 + Battery_Gem_2.ID, GTValues.V[7] * 20 * 300 / 4, GTValues.V[7], 7L, -3L, false); + this.setElectricStats(32000 + Battery_Gem_3.ID, GTValues.V[8] * 20 * 300 / 4, GTValues.V[8], 8L, -3L, false); + this.setElectricStats(32000 + Battery_Casing_Gem_4.ID, (64000000000L * 16), GTValues.V[9], 9L, -3L, false); this.setElectricStats( 32000 + Gregtech_Computer_Cube.ID, - GT_Values.V[6] * 10 * 60 * 20, - GT_Values.V[5], + GTValues.V[6] * 10 * 60 * 20, + GTValues.V[5], 5L, -3L, false); @@ -331,36 +331,36 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { } private void registerFuelRTGRecipes() { - GT_Values.RA.stdBuilder() + GTValues.RA.stdBuilder() .itemInputs(GregtechItemList.Pellet_RTG_PU238.get(1)) .duration(0) .eut(64) .metadata(RTG_DURATION_IN_DAYS, MathUtils.roundToClosestInt(87.7f)) .addTo(rtgFuels); - GT_Values.RA.stdBuilder() + GTValues.RA.stdBuilder() .itemInputs(GregtechItemList.Pellet_RTG_SR90.get(1)) .duration(0) .eut(TierEU.RECIPE_LV) .metadata(RTG_DURATION_IN_DAYS, MathUtils.roundToClosestInt(28.8f)) .addTo(rtgFuels); - GT_Values.RA.stdBuilder() + GTValues.RA.stdBuilder() .itemInputs(GregtechItemList.Pellet_RTG_PO210.get(1)) .duration(0) .eut(TierEU.RECIPE_HV) .metadata(RTG_DURATION_IN_DAYS, 1) .addTo(rtgFuels); - GT_Values.RA.stdBuilder() + GTValues.RA.stdBuilder() .itemInputs(GregtechItemList.Pellet_RTG_AM241.get(1)) .duration(0) .eut(16) .metadata(RTG_DURATION_IN_DAYS, 216) .addTo(rtgFuels); - GT_Values.RA.stdBuilder() - .itemInputs(GT_ModHandler.getIC2Item("RTGPellets", 1)) + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getIC2Item("RTGPellets", 1)) .duration(0) .eut(8) .metadata(RTG_DURATION_IN_DAYS, MathUtils.roundToClosestInt(2.6f)) @@ -368,36 +368,36 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { } private void registerCovers() { - GregTech_API.registerCover( + GregTechAPI.registerCover( GregtechItemList.Cover_Overflow_LV.get(1L), - new GT_MultiTexture( + new GTMultiTexture( Textures.BlockIcons.MACHINE_CASINGS[4][0], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), - new GTPP_Cover_Overflow(64)); - GregTech_API.registerCover( + new GTRenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), + new CoverOverflow(64)); + GregTechAPI.registerCover( GregtechItemList.Cover_Overflow_MV.get(1L), - new GT_MultiTexture( + new GTMultiTexture( Textures.BlockIcons.MACHINE_CASINGS[5][0], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), - new GTPP_Cover_Overflow(512)); - GregTech_API.registerCover( + new GTRenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), + new CoverOverflow(512)); + GregTechAPI.registerCover( GregtechItemList.Cover_Overflow_HV.get(1L), - new GT_MultiTexture( + new GTMultiTexture( Textures.BlockIcons.MACHINE_CASINGS[5][0], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), - new GTPP_Cover_Overflow(4096)); - GregTech_API.registerCover( + new GTRenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), + new CoverOverflow(4096)); + GregTechAPI.registerCover( GregtechItemList.Cover_Overflow_EV.get(1L), - new GT_MultiTexture( + new GTMultiTexture( Textures.BlockIcons.MACHINE_CASINGS[8][0], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), - new GTPP_Cover_Overflow(32768)); - GregTech_API.registerCover( + new GTRenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), + new CoverOverflow(32768)); + GregTechAPI.registerCover( GregtechItemList.Cover_Overflow_IV.get(1L), - new GT_MultiTexture( + new GTMultiTexture( Textures.BlockIcons.MACHINE_CASINGS[8][0], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), - new GTPP_Cover_Overflow(262144)); + new GTRenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)), + new CoverOverflow(262144)); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java index 30250a46f3..ddc90a0183 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -1,24 +1,24 @@ package gtPlusPlus.xmod.gregtech.common.items; -import gregtech.api.GregTech_API; -import gregtech.api.enums.TC_Aspects; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.TCAspects; import gregtech.api.enums.ToolDictNames; -import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.items.MetaGeneratedTool; import gtPlusPlus.xmod.gregtech.api.enums.GregtechToolDictNames; -import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_AngleGrinder; -import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricSnips; +import gtPlusPlus.xmod.gregtech.common.tools.ToolAngleGrinder; +import gtPlusPlus.xmod.gregtech.common.tools.ToolElectricSnips; -public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { +public class MetaGeneratedGregtechTools extends MetaGeneratedTool { public static final short ANGLE_GRINDER = 7834; public static final short ELECTRIC_SNIPS = 7934; - public static GT_MetaGenerated_Tool INSTANCE; + public static MetaGeneratedTool INSTANCE; static { INSTANCE = new MetaGeneratedGregtechTools(); } - public static GT_MetaGenerated_Tool getInstance() { + public static MetaGeneratedTool getInstance() { return INSTANCE; } @@ -30,25 +30,25 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { ANGLE_GRINDER, "Angle Grinder", "Hand-held electric filing device", - new TOOL_Gregtech_AngleGrinder(), + new ToolAngleGrinder(), GregtechToolDictNames.craftingToolAngleGrinder, ToolDictNames.craftingToolFile, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L)); + new TCAspects.TC_AspectStack(TCAspects.INSTRUMENTUM, 2L), + new TCAspects.TC_AspectStack(TCAspects.FABRICO, 2L), + new TCAspects.TC_AspectStack(TCAspects.ORDO, 2L)); // Electric Wire Cutter - GregTech_API.registerWireCutter( + GregTechAPI.registerWireCutter( this.addTool( ELECTRIC_SNIPS, "Automatic Snips", "Hand-held electric wire cutter", - new TOOL_Gregtech_ElectricSnips(), + new ToolElectricSnips(), GregtechToolDictNames.craftingToolElectricSnips, ToolDictNames.craftingToolWireCutter, - new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L))); + new TCAspects.TC_AspectStack(TCAspects.INSTRUMENTUM, 4L), + new TCAspects.TC_AspectStack(TCAspects.FABRICO, 4L), + new TCAspects.TC_AspectStack(TCAspects.ORDO, 4L))); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedItemIDs.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedItemIDs.java new file mode 100644 index 0000000000..72f5c66c58 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedItemIDs.java @@ -0,0 +1,47 @@ +package gtPlusPlus.xmod.gregtech.common.items; + +public enum MetaGeneratedItemIDs { + + Shape_Extruder_WindmillShaft(40), + Pellet_RTG_PU238(41), + Pellet_RTG_SR90(42), + Pellet_RTG_PO210(43), + Pellet_RTG_AM241(44), + Battery_RE_EV_Sodium(50), + Battery_RE_EV_Cadmium(52), + Battery_RE_EV_Lithium(54), + Gregtech_Computer_Cube(55), + Battery_Gem_1(66), + Battery_Gem_2(68), + Battery_Gem_3(70), + Cover_Overflow_LV(72), + Cover_Overflow_MV(73), + Cover_Overflow_HV(74), + Cover_Overflow_EV(75), + Cover_Overflow_IV(76), + Compressed_Fusion_Reactor(100), + Laser_Lens_Special(105), + Battery_Casing_Gem_1(106), + Battery_Casing_Gem_2(107), + Battery_Casing_Gem_3(108), + Battery_Casing_Gem_4(109), + Battery_Gem_4(110), + Laser_Lens_WoodsGlass(140), + TransmissionComponent_LV(142), + TransmissionComponent_MV(143), + TransmissionComponent_HV(144), + TransmissionComponent_EV(145), + TransmissionComponent_IV(146), + TransmissionComponent_LuV(147), + TransmissionComponent_ZPM(148), + TransmissionComponent_UV(149), + TransmissionComponent_UHV(150), + Distillus_Upgrade_Chip(151), + Maceration_Upgrade_Chip(152); + + public final int ID; + + MetaGeneratedItemIDs(int ID) { + this.ID = ID; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java index f85822750d..be7a0f1c99 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java @@ -7,31 +7,31 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.items.behaviors.Behaviour_None; -import gregtech.common.items.behaviors.Behaviour_Wrench; +import gregtech.api.items.MetaBaseItem; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.items.behaviors.BehaviourNone; +import gregtech.common.items.behaviors.BehaviourWrench; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -public class Behaviour_Choocher extends Behaviour_None { +public class Behaviour_Choocher extends BehaviourNone { private boolean isWrench = true; - private final Behaviour_Wrench wrench = new Behaviour_Wrench(150); + private final BehaviourWrench wrench = new BehaviourWrench(150); private final Behaviour_Prospecting_Ex prospecting = new Behaviour_Prospecting_Ex(10, 1250); - private final String mTooltip1 = GT_LanguageManager + private final String mTooltip1 = GTLanguageManager .addStringLocalization("gt.behaviour.choochering1", "Current tool mode: "); - private final String mTooltip2 = GT_LanguageManager + private final String mTooltip2 = GTLanguageManager .addStringLocalization("gt.behaviour.choochering2", "Change tool mode using Shift+Rightclick."); - private final String mTooltipH = GT_LanguageManager + private final String mTooltipH = GTLanguageManager .addStringLocalization("gt.behaviour.prospectingEx", "Usable for Prospecting large areas."); - private final String mTooltipW = GT_LanguageManager + private final String mTooltipW = GTLanguageManager .addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick."); public Behaviour_Choocher() {} @Override - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, + public boolean onItemUseFirst(final MetaBaseItem aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final ForgeDirection side, final float hitX, final float hitY, final float hitZ) { if (aWorld.isRemote) { @@ -64,7 +64,7 @@ public class Behaviour_Choocher extends Behaviour_None { } @Override - public List getAdditionalToolTips(final GT_MetaBase_Item aItem, final List aList, + public List getAdditionalToolTips(final MetaBaseItem aItem, final List aList, final ItemStack aStack) { boolean inWrenchMode; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java index f3d7f87a86..c458d237bd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java @@ -13,37 +13,37 @@ import net.minecraftforge.common.util.ForgeDirection; import codechicken.lib.math.MathHelper; import gregtech.api.enums.SoundResource; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.common.items.behaviors.Behaviour_None; +import gregtech.api.items.MetaBaseItem; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.common.items.behaviors.BehaviourNone; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.entity.projectile.EntityLightningAttack; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import ic2.api.item.IElectricItemManager; -public class Behaviour_Electric_Lighter extends Behaviour_None { +public class Behaviour_Electric_Lighter extends BehaviourNone { - private final String mTooltip = GT_LanguageManager + private final String mTooltip = GTLanguageManager .addStringLocalization("gt.behaviour.lighter.tooltip", "Can light things on Fire"); - private final String mTooltipUses = GT_LanguageManager + private final String mTooltipUses = GTLanguageManager .addStringLocalization("gt.behaviour.lighter.uses", "Remaining Uses:"); - private final String mTooltipUnstackable = GT_LanguageManager + private final String mTooltipUnstackable = GTLanguageManager .addStringLocalization("gt.behaviour.unstackable", "Not usable when stacked!"); public Behaviour_Electric_Lighter() {} @Override - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + public boolean onLeftClickEntity(MetaBaseItem aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { if (!aPlayer.worldObj.isRemote && aStack != null && aStack.stackSize == 1) { boolean rOutput = false; if (aEntity instanceof EntityCreeper) { if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { - GT_Utility.sendSoundToPlayers( + GTUtility.sendSoundToPlayers( aPlayer.worldObj, SoundResource.FIRE_IGNITE, 1.0F, @@ -62,8 +62,8 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { } @Override - public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { + public boolean onItemUse(MetaBaseItem aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, + int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { if (aPlayer.isSneaking()) { Logger.INFO("Changing Mode"); @@ -81,8 +81,11 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); if (aCurrentMode) { // Shoot Lightning Attack - aWorld - .playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + aWorld.playSoundAtEntity( + aPlayer, + "random.bow", + 0.5F, + 0.4F / (GTPPCore.RANDOM.nextFloat() * 0.4F + 0.8F)); if (!aWorld.isRemote) { aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); } @@ -94,12 +97,12 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { aX += tDirection.offsetX; aY += tDirection.offsetY; aZ += tDirection.offsetZ; - if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) + if (GTUtility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, ordinalSide, aStack)) { Logger.WARNING("Preparing Lighter b"); if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { Logger.WARNING("Preparing Lighter c"); - GT_Utility.sendSoundToPlayers(aWorld, SoundResource.FIRE_IGNITE, 1.0F, 1.0F, aX, aY, aZ); + GTUtility.sendSoundToPlayers(aWorld, SoundResource.FIRE_IGNITE, 1.0F, 1.0F, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, Blocks.fire); rOutput = true; // ItemNBT.setLighterFuel(aStack, tFuelAmount); @@ -113,7 +116,7 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { return false; } - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, + public boolean onItemUseFirst(MetaBaseItem aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { if (aPlayer.isSneaking()) { @@ -132,8 +135,11 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); if (aCurrentMode) { // Shoot Lightning Attack - aWorld - .playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + aWorld.playSoundAtEntity( + aPlayer, + "random.bow", + 0.5F, + 0.4F / (GTPPCore.RANDOM.nextFloat() * 0.4F + 0.8F)); if (!aWorld.isRemote) { aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); } @@ -145,12 +151,12 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { aX += tDirection.offsetX; aY += tDirection.offsetY; aZ += tDirection.offsetZ; - if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) + if (GTUtility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, ordinalSide, aStack)) { Logger.WARNING("Preparing Lighter b"); if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { Logger.WARNING("Preparing Lighter c"); - GT_Utility.sendSoundToPlayers(aWorld, SoundResource.FIRE_IGNITE, 1.0F, 1.0F, aX, aY, aZ); + GTUtility.sendSoundToPlayers(aWorld, SoundResource.FIRE_IGNITE, 1.0F, 1.0F, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, Blocks.fire); rOutput = true; // ItemNBT.setLighterFuel(aStack, tFuelAmount); @@ -191,7 +197,7 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { private void useUp(ItemStack aStack) {} @Override - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + public List getAdditionalToolTips(MetaBaseItem aItem, List aList, ItemStack aStack) { aList.add(this.mTooltip); int aUses = 0; if (aStack != null) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java index 5749204296..f63da57f1c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java @@ -11,20 +11,20 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidBlock; -import gregtech.api.GregTech_API; +import gregtech.api.GregTechAPI; import gregtech.api.enums.Materials; import gregtech.api.enums.SoundResource; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.items.MetaBaseItem; +import gregtech.api.items.MetaGeneratedTool; import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Block_Ores; -import gregtech.common.blocks.GT_TileEntity_Ores; -import gregtech.common.items.behaviors.Behaviour_Prospecting; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import gregtech.common.blocks.BlockOres; +import gregtech.common.blocks.TileEntityOres; +import gregtech.common.items.behaviors.BehaviourProspecting; -public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { +public class Behaviour_Prospecting_Ex extends BehaviourProspecting { private final int mVanillaCosts; private final int mEUCosts; @@ -36,7 +36,7 @@ public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { } @Override - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, + public boolean onItemUseFirst(final MetaBaseItem aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final ForgeDirection side, final float hitX, final float hitY, final float hitZ) { if (aWorld.isRemote) { @@ -48,28 +48,28 @@ public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { } final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); + ItemData tAssotiation = GTOreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); if ((tAssotiation != null) && (tAssotiation.mPrefix.toString() .startsWith("ore"))) { - GT_Utility + GTUtility .sendChatToPlayer(aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - GT_Utility.sendSoundToPlayers(aWorld, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1.0F, aX, aY, aZ); + GTUtility.sendSoundToPlayers(aWorld, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1.0F, aX, aY, aZ); return true; } if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) - || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTechAPI.sBlockGranites)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.grass))) { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1.0F, aX, aY, aZ); + if (GTModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + GTUtility.sendSoundToPlayers(aWorld, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1.0F, aX, aY, aZ); int tX = aX; int tY = aY; int tZ = aZ; int tMetaID = 0; - final int tQuality = ((aItem instanceof GT_MetaGenerated_Tool) - ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") + final int tQuality = ((aItem instanceof MetaGeneratedTool) + ? ((MetaGeneratedTool) aItem).getHarvestLevel(aStack, "") : 0) * 3; int i = 0; @@ -80,23 +80,23 @@ public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { final Block tBlock = aWorld.getBlock(tX, tY, tZ); if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { - GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Block."); + GTUtility.sendChatToPlayer(aPlayer, "There is Lava behind this Block."); break; } if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Block."); + GTUtility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Block."); break; } - if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Block."); + if ((tBlock == Blocks.monster_egg) || (!GTUtility.hasBlockHitBox(aWorld, tX, tY, tZ))) { + GTUtility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Block."); break; } if (tBlock != aBlock) { if (i >= 4) { break; } - GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Block."); + GTUtility.sendChatToPlayer(aPlayer, "Material is changing behind this Block."); break; } } @@ -107,13 +107,13 @@ public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { tY = (aY - 4 - tQuality) + tRandom.nextInt(j); tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock instanceof GT_Block_Ores)) { + if ((tBlock instanceof BlockOres)) { final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData + if ((tTileEntity instanceof TileEntityOres)) { + final Materials tMaterial = GregTechAPI.sGeneratedMaterials[(((TileEntityOres) tTileEntity).mMetaData % 1000)]; if ((tMaterial != null) && (tMaterial != Materials._NULL)) { - GT_Utility.sendChatToPlayer( + GTUtility.sendChatToPlayer( aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); return true; @@ -121,17 +121,17 @@ public class Behaviour_Prospecting_Ex extends Behaviour_Prospecting { } } else { tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); - tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + tAssotiation = GTOreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); if ((tAssotiation != null) && (tAssotiation.mPrefix.toString() .startsWith("ore"))) { - GT_Utility.sendChatToPlayer( + GTUtility.sendChatToPlayer( aPlayer, "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); return true; } } } - GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); + GTUtility.sendChatToPlayer(aPlayer, "No Ores found."); } return true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java index 987924952a..399554d306 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java @@ -8,7 +8,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; -import gregtech.api.enums.GT_Values; +import gregtech.api.enums.GTValues; import gregtech.api.enums.Textures; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; @@ -45,6 +45,6 @@ public class MetaItemCoverCasings extends MetaCustomCoverItem { public String getItemStackDisplayName(final ItemStack tItem) { return EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocalFormatted( "item.itemCustomMetaCover.miscutils.GtMachineCasings", - GT_Values.VOLTAGE_NAMES[MathUtils.balance(tItem.getItemDamage(), 0, GT_Values.VOLTAGE_NAMES.length - 1)]); // super.getItemStackDisplayName(tItem); + GTValues.VOLTAGE_NAMES[MathUtils.balance(tItem.getItemDamage(), 0, GTValues.VOLTAGE_NAMES.length - 1)]); // super.getItemStackDisplayName(tItem); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java new file mode 100644 index 0000000000..f9ec4b9433 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java @@ -0,0 +1,500 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ForkJoinPool; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.apache.commons.io.IOUtils; +import org.lwjgl.opengl.GL11; + +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.lib.GTPPCore.ConfigSwitches; +import gtPlusPlus.core.proxy.ClientProxy; +import gtPlusPlus.core.util.data.AES; +import gtPlusPlus.core.util.data.FileUtils; +import gtPlusPlus.core.util.math.MathUtils; + +public class CapeRenderer extends RenderPlayer { + + private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), + new ResourceLocation("miscutils:textures/FancyCapeHD.png"), + new ResourceLocation("miscutils:textures/TesterCapeHD.png"), + new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), + new ResourceLocation("miscutils:textures/DevCapeHD.png"), }; + + private final boolean mInit; + + public CapeRenderer() { + mInit = init(); + } + + private boolean init() { + if (mInit) { + return false; + } + return CapeUtils.init(); + } + + private static boolean hasResourceChecked = false; + private static boolean hasSetRenderer = false; + private boolean hasCape = false; + private ResourceLocation tResource = null; + + public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + + // Check we have set Render Manager + if (this.renderManager == null) { + hasSetRenderer = false; + } + + // Set Render Manager + if (!hasSetRenderer) { + if (RenderManager.instance != null) { + setRenderManager(RenderManager.instance); + hasSetRenderer = true; + } + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { + return; + } + + if (!CapeUtils.mapsPopulated) { + if (!CapeUtils.cacheReady) { + return; + } + CapeUtils.writeCacheToMaps(); + CapeUtils.mapsPopulated = true; + } + + // We have already checked if this player has a cape, but since they do not, we best not render. + if (hasResourceChecked) { + if (!hasCape && !GTPPCore.DEVENV) { + return; + } + } + + // Allocate client player object + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + + // Make sure we don't keep checking on clients who dont have capes. + if (!hasResourceChecked) { + + // Get players UUID + String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile() + .getId() + .toString() : "BAD"; + + // If for whatever reason this fails, we just exit early. + if (aPlayerUUID.equals("BAD")) { + return; + } + + // Automatically allocate a Dev cape while in Dev mode. + if (tResource == null && GTPPCore.DEVENV) { + tResource = mCapes[4]; + hasCape = true; + } + + String aPlayerName = ClientProxy.playerName; + + // Check cape lists for the cape this player owns. + if (!hasCape) { + for (Pair aData : CapeUtils.mOrangeCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[0]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mMiscCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[1]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mBetaTestCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[2]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mPatreonCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[3]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mDevCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[4]; + hasCape = true; + break; + } + } + } + hasResourceChecked = true; + } + + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } + } + } + + private boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { + float aPartialTicks = aEvent.partialRenderTick; + try { + if (tResource == null && GTPPCore.DEVENV) { + tResource = mCapes[3]; + } + + // If player is invisible, don't render. + if (GTUtility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() + || GTUtility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id))) { + aEvent.setCanceled(true); + return false; + } + + if ((tResource != null) && (!aPlayer.getHideCape())) { + bindTexture(tResource); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks + - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); + double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks + - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); + double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks + - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); + float f6 = aPlayer.prevRenderYawOffset + + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; + double d3 = MathHelper.sin(f6 * GTPPCore.PI / 180.0F); + double d4 = -MathHelper.cos(f6 * GTPPCore.PI / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; + float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; + if (f7 < -6.0F) { + f7 = -6.0F; + } + if (f7 > 32.0F) { + f7 = 32.0F; + } + if (f8 < 0.0F) { + f8 = 0.0F; + } + float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; + f7 += MathHelper.sin( + (aPlayer.prevDistanceWalkedModified + + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) + * 32.0F + * f10; + if (aPlayer.isSneaking()) { + f7 += 25.0F; + } + GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + ((ModelBiped) this.mainModel).renderCloak(0.0625F); + GL11.glPopMatrix(); + return true; + } + } catch (Throwable e) { + + } + return false; + } + + private static class CapeUtils { + + private static char SPLIT_CHARACTER = '§'; + private static AES sAES; + private static volatile boolean cacheReady = false; + private static boolean mapsPopulated = false; + + // UUID - Username + private static final AutoMap> mOrangeCapes = new AutoMap<>(); + private static final AutoMap> mMiscCapes = new AutoMap<>(); + private static final AutoMap> mBetaTestCapes = new AutoMap<>(); + private static final AutoMap> mPatreonCapes = new AutoMap<>(); + private static final AutoMap> mDevCapes = new AutoMap<>(); + + private static boolean init() { + CapeUtils.handleOldCapeCache(); + if (GTPPCore.DEVENV) { + return true; + } + ForkJoinPool.commonPool() + .execute(() -> { + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } catch (Exception ignored) {} + cacheReady = true; + }); + return true; + } + + private static boolean shouldDownloadCapeList() { + if (!doesCapeCacheExistLocally()) { + return true; + } + if (isCapeCacheWeekOld()) { + return true; + } + return false; + } + + private static boolean isCapeCacheWeekOld() { + if (!doesCapeCacheExistLocally()) { + return true; + } else { + File dat = CapeUtils.getCapeCache(); + Date dateLastMod = new Date(dat.lastModified()); + Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); + if (dateLastMod.before(dateNow)) { + return true; + } + } + return false; + } + + private static void downloadCapeList() { + try { + File dat = getCapeCache(); + File temp = allocateTempFile(); + InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); + FileOutputStream fileOS = new FileOutputStream(temp); + IOUtils.copy(inputStream, fileOS); + if (isDownloadedCapeListBigger(temp)) { + fileOS = new FileOutputStream(dat); + IOUtils.copy(inputStream, fileOS); + } + } catch (Throwable t) { + Logger.INFO("Unable to download GT++ cape list."); + } + } + + private static boolean isDownloadedCapeListBigger(File aFile) { + double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); + double aNewFileSize = aFile.length(); + if (aNewFileSize > aExistingFileSize) { + return true; + } + return false; + } + + private static void handleOldCapeCache() { + File aCacheFile = FileUtils.getFile("GTPP", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + aCacheFile.delete(); + } + } + + private static boolean doesCapeCacheExistLocally() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + return true; + } + return false; + } + + private static File getCapeCache() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + FileUtils.createFile(aCacheFile); + } + return aCacheFile; + } + + public static final List getDataFromCache() { + File aCacheFile = getCapeCache(); + List aCache = FileUtils.readLines(aCacheFile); + if (aCache != null && !aCache.isEmpty()) { + return aCache; + } + return new AutoMap<>(); + } + + private static File allocateTempFile() { + File tempFile = null; + try { + tempFile = File.createTempFile("gtpp-", null); + } catch (IOException e) { + e.printStackTrace(); + } + if (tempFile == null) { + tempFile = FileUtils + .createFile("", "gtpp-" + MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE / 2)), "tmp"); + } + tempFile.deleteOnExit(); + return tempFile; + } + + public static final void writeCacheToMaps() { + List aCacheData = getDataFromCache(); + if (aCacheData != null && !aCacheData.isEmpty()) { + if (sAES == null) { + sAES = new AES(); + } + AutoMap aDecodedData = new AutoMap<>(); + for (String aToDecode : aCacheData) { + aDecodedData.put(sAES.decode(aToDecode)); + } + if (!aDecodedData.isEmpty()) { + AutoMap> aCapeType1 = new AutoMap<>(); + AutoMap> aCapeType2 = new AutoMap<>(); + AutoMap> aCapeType3 = new AutoMap<>(); + AutoMap> aCapeType4 = new AutoMap<>(); + AutoMap> aCapeType5 = new AutoMap<>(); + boolean didProcessStringData = false; + Logger.INFO("Decoded String Count: " + aDecodedData.size()); + for (String aToSplit : aDecodedData) { + String[] aSplitData = aToSplit.split("" + SPLIT_CHARACTER); + if (aSplitData != null && aSplitData.length >= 2) { + if (aSplitData[0] != null) { + Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); + if (aCapeTypeID2 != null) { + int aCapeTypeID = aCapeTypeID2; + Pair aFinalString = new Pair<>( + "UUID: " + aSplitData[1], + "Username: " + + (aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] + : "Not Specified")); + Logger.INFO("Cape Type: " + aCapeTypeID); + switch (aCapeTypeID) { + case 0 -> { + aCapeType1.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType1.size() + + " users."); + } + case 1 -> { + aCapeType2.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType2.size() + + " users."); + } + case 2 -> { + aCapeType3.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType3.size() + + " users."); + } + case 3 -> { + aCapeType4.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType4.size() + + " users."); + } + case 4 -> { + aCapeType5.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType5.size() + + " users."); + } + default -> {} + } + } + } + } + } + if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() + || !aCapeType3.isEmpty() + || !aCapeType4.isEmpty() + || !aCapeType5.isEmpty()) { + didProcessStringData = true; + } else { + // did not process any data + } + if (didProcessStringData) { + if (!aCapeType1.isEmpty()) { + for (Pair aUser : aCapeType1) { + Logger.INFO("Adding Generic cape for " + aUser.getKey()); + mOrangeCapes.add(aUser); + } + } + if (!aCapeType2.isEmpty()) { + for (Pair aUser : aCapeType2) { + Logger.INFO("Adding Blue cape for " + aUser.getKey()); + mMiscCapes.add(aUser); + } + } + if (!aCapeType3.isEmpty()) { + for (Pair aUser : aCapeType3) { + Logger.INFO("Adding Beta cape for " + aUser.getKey()); + mBetaTestCapes.add(aUser); + } + } + if (!aCapeType4.isEmpty()) { + for (Pair aUser : aCapeType4) { + Logger.INFO("Adding Patreon cape for " + aUser.getKey()); + mPatreonCapes.add(aUser); + } + } + if (!aCapeType5.isEmpty()) { + for (Pair aUser : aCapeType5) { + Logger.INFO("Adding Dev cape for " + aUser.getKey()); + mDevCapes.add(aUser); + } + } + } + } else { + // No data decoded + } + } else { + // Nothing was cached? + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java new file mode 100644 index 0000000000..20d904ae80 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java @@ -0,0 +1,107 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +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 net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.items.ItemVolumetricFlask; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import ic2.core.util.DrawUtil; + +@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) +public final class FlaskRenderer implements net.minecraftforge.client.IItemRenderer { + + public FlaskRenderer() { + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.FIRST_PERSON_MAP; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + return type == ItemRenderType.ENTITY; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + ItemVolumetricFlask cell = (ItemVolumetricFlask) item.getItem(); + + int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; + IIcon icon = item.getIconIndex(); + GL11.glEnable(3042); + GL11.glEnable(3008); + if (type.equals(ItemRenderType.ENTITY)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); + GL11.glTranslated(-0.5D, -0.6D, 0.0D); + } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { + GL11.glTranslated(1.0D, 1.0D, 0.0D); + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + } else if (type.equals(ItemRenderType.EQUIPPED)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glTranslated(-1.0D, -1.0D, 0.0D); + } + + FluidStack fs = cell.getFluid(item); + if (fs != null) { + IIcon iconWindow = cell.iconWindow; + IIcon fluidicon = fs.getFluid() + .getIcon(fs); + int fluidColor = fs.getFluid() + .getColor(fs); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(0, 1); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glBlendFunc(770, 771); + GL11.glDepthFunc(514); + GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); + GL11.glDepthFunc(515); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); + } + GL11.glDisable(3008); + GL11.glDisable(3042); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java deleted file mode 100644 index a281a205d2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ /dev/null @@ -1,500 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ForkJoinPool; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderPlayerEvent; - -import org.apache.commons.io.IOUtils; -import org.lwjgl.opengl.GL11; - -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.CORE.ConfigSwitches; -import gtPlusPlus.core.proxy.ClientProxy; -import gtPlusPlus.core.util.data.AES; -import gtPlusPlus.core.util.data.FileUtils; -import gtPlusPlus.core.util.math.MathUtils; - -public class GTPP_CapeRenderer extends RenderPlayer { - - private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), - new ResourceLocation("miscutils:textures/FancyCapeHD.png"), - new ResourceLocation("miscutils:textures/TesterCapeHD.png"), - new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), - new ResourceLocation("miscutils:textures/DevCapeHD.png"), }; - - private final boolean mInit; - - public GTPP_CapeRenderer() { - mInit = init(); - } - - private boolean init() { - if (mInit) { - return false; - } - return CapeUtils.init(); - } - - private static boolean hasResourceChecked = false; - private static boolean hasSetRenderer = false; - private boolean hasCape = false; - private ResourceLocation tResource = null; - - public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { - - // Check we have set Render Manager - if (this.renderManager == null) { - hasSetRenderer = false; - } - - // Set Render Manager - if (!hasSetRenderer) { - if (RenderManager.instance != null) { - setRenderManager(RenderManager.instance); - hasSetRenderer = true; - } - } - - // Actually Render - if (hasSetRenderer) { - - // We have capes turned off, so let's not render. - if (!ConfigSwitches.enableCustomCapes) { - return; - } - - if (!CapeUtils.mapsPopulated) { - if (!CapeUtils.cacheReady) { - return; - } - CapeUtils.writeCacheToMaps(); - CapeUtils.mapsPopulated = true; - } - - // We have already checked if this player has a cape, but since they do not, we best not render. - if (hasResourceChecked) { - if (!hasCape && !CORE.DEVENV) { - return; - } - } - - // Allocate client player object - AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - - // Make sure we don't keep checking on clients who dont have capes. - if (!hasResourceChecked) { - - // Get players UUID - String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile() - .getId() - .toString() : "BAD"; - - // If for whatever reason this fails, we just exit early. - if (aPlayerUUID.equals("BAD")) { - return; - } - - // Automatically allocate a Dev cape while in Dev mode. - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[4]; - hasCape = true; - } - - String aPlayerName = ClientProxy.playerName; - - // Check cape lists for the cape this player owns. - if (!hasCape) { - for (Pair aData : CapeUtils.mOrangeCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[0]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mMiscCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[1]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mBetaTestCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[2]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mPatreonCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[3]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mDevCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[4]; - hasCape = true; - break; - } - } - } - hasResourceChecked = true; - } - - if (hasResourceChecked) { - // We have met all the conditions, let's render that cape. - renderCapeOnPlayer(aEvent, aPlayer); - } - } - } - - private boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { - float aPartialTicks = aEvent.partialRenderTick; - try { - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[3]; - } - - // If player is invisible, don't render. - if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() - || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id))) { - aEvent.setCanceled(true); - return false; - } - - if ((tResource != null) && (!aPlayer.getHideCape())) { - bindTexture(tResource); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, 0.125F); - double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks - - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); - double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks - - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); - double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks - - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); - float f6 = aPlayer.prevRenderYawOffset - + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; - double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F); - double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F); - float f7 = (float) d1 * 10.0F; - float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; - float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; - if (f7 < -6.0F) { - f7 = -6.0F; - } - if (f7 > 32.0F) { - f7 = 32.0F; - } - if (f8 < 0.0F) { - f8 = 0.0F; - } - float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; - f7 += MathHelper.sin( - (aPlayer.prevDistanceWalkedModified - + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) - * 32.0F - * f10; - if (aPlayer.isSneaking()) { - f7 += 25.0F; - } - GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - ((ModelBiped) this.mainModel).renderCloak(0.0625F); - GL11.glPopMatrix(); - return true; - } - } catch (Throwable e) { - - } - return false; - } - - private static class CapeUtils { - - private static char SPLIT_CHARACTER = '§'; - private static AES sAES; - private static volatile boolean cacheReady = false; - private static boolean mapsPopulated = false; - - // UUID - Username - private static final AutoMap> mOrangeCapes = new AutoMap<>(); - private static final AutoMap> mMiscCapes = new AutoMap<>(); - private static final AutoMap> mBetaTestCapes = new AutoMap<>(); - private static final AutoMap> mPatreonCapes = new AutoMap<>(); - private static final AutoMap> mDevCapes = new AutoMap<>(); - - private static boolean init() { - CapeUtils.handleOldCapeCache(); - if (CORE.DEVENV) { - return true; - } - ForkJoinPool.commonPool() - .execute(() -> { - try { - if (shouldDownloadCapeList()) { - downloadCapeList(); - } - } catch (Exception ignored) {} - cacheReady = true; - }); - return true; - } - - private static boolean shouldDownloadCapeList() { - if (!doesCapeCacheExistLocally()) { - return true; - } - if (isCapeCacheWeekOld()) { - return true; - } - return false; - } - - private static boolean isCapeCacheWeekOld() { - if (!doesCapeCacheExistLocally()) { - return true; - } else { - File dat = CapeUtils.getCapeCache(); - Date dateLastMod = new Date(dat.lastModified()); - Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); - if (dateLastMod.before(dateNow)) { - return true; - } - } - return false; - } - - private static void downloadCapeList() { - try { - File dat = getCapeCache(); - File temp = allocateTempFile(); - InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); - FileOutputStream fileOS = new FileOutputStream(temp); - IOUtils.copy(inputStream, fileOS); - if (isDownloadedCapeListBigger(temp)) { - fileOS = new FileOutputStream(dat); - IOUtils.copy(inputStream, fileOS); - } - } catch (Throwable t) { - Logger.INFO("Unable to download GT++ cape list."); - } - } - - private static boolean isDownloadedCapeListBigger(File aFile) { - double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); - double aNewFileSize = aFile.length(); - if (aNewFileSize > aExistingFileSize) { - return true; - } - return false; - } - - private static void handleOldCapeCache() { - File aCacheFile = FileUtils.getFile("GTPP", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - aCacheFile.delete(); - } - } - - private static boolean doesCapeCacheExistLocally() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - return true; - } - return false; - } - - private static File getCapeCache() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - FileUtils.createFile(aCacheFile); - } - return aCacheFile; - } - - public static final List getDataFromCache() { - File aCacheFile = getCapeCache(); - List aCache = FileUtils.readLines(aCacheFile); - if (aCache != null && !aCache.isEmpty()) { - return aCache; - } - return new AutoMap<>(); - } - - private static File allocateTempFile() { - File tempFile = null; - try { - tempFile = File.createTempFile("gtpp-", null); - } catch (IOException e) { - e.printStackTrace(); - } - if (tempFile == null) { - tempFile = FileUtils - .createFile("", "gtpp-" + MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE / 2)), "tmp"); - } - tempFile.deleteOnExit(); - return tempFile; - } - - public static final void writeCacheToMaps() { - List aCacheData = getDataFromCache(); - if (aCacheData != null && !aCacheData.isEmpty()) { - if (sAES == null) { - sAES = new AES(); - } - AutoMap aDecodedData = new AutoMap<>(); - for (String aToDecode : aCacheData) { - aDecodedData.put(sAES.decode(aToDecode)); - } - if (!aDecodedData.isEmpty()) { - AutoMap> aCapeType1 = new AutoMap<>(); - AutoMap> aCapeType2 = new AutoMap<>(); - AutoMap> aCapeType3 = new AutoMap<>(); - AutoMap> aCapeType4 = new AutoMap<>(); - AutoMap> aCapeType5 = new AutoMap<>(); - boolean didProcessStringData = false; - Logger.INFO("Decoded String Count: " + aDecodedData.size()); - for (String aToSplit : aDecodedData) { - String[] aSplitData = aToSplit.split("" + SPLIT_CHARACTER); - if (aSplitData != null && aSplitData.length >= 2) { - if (aSplitData[0] != null) { - Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); - if (aCapeTypeID2 != null) { - int aCapeTypeID = aCapeTypeID2; - Pair aFinalString = new Pair<>( - "UUID: " + aSplitData[1], - "Username: " - + (aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] - : "Not Specified")); - Logger.INFO("Cape Type: " + aCapeTypeID); - switch (aCapeTypeID) { - case 0 -> { - aCapeType1.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType1.size() - + " users."); - } - case 1 -> { - aCapeType2.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType2.size() - + " users."); - } - case 2 -> { - aCapeType3.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType3.size() - + " users."); - } - case 3 -> { - aCapeType4.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType4.size() - + " users."); - } - case 4 -> { - aCapeType5.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType5.size() - + " users."); - } - default -> {} - } - } - } - } - } - if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() - || !aCapeType3.isEmpty() - || !aCapeType4.isEmpty() - || !aCapeType5.isEmpty()) { - didProcessStringData = true; - } else { - // did not process any data - } - if (didProcessStringData) { - if (!aCapeType1.isEmpty()) { - for (Pair aUser : aCapeType1) { - Logger.INFO("Adding Generic cape for " + aUser.getKey()); - mOrangeCapes.add(aUser); - } - } - if (!aCapeType2.isEmpty()) { - for (Pair aUser : aCapeType2) { - Logger.INFO("Adding Blue cape for " + aUser.getKey()); - mMiscCapes.add(aUser); - } - } - if (!aCapeType3.isEmpty()) { - for (Pair aUser : aCapeType3) { - Logger.INFO("Adding Beta cape for " + aUser.getKey()); - mBetaTestCapes.add(aUser); - } - } - if (!aCapeType4.isEmpty()) { - for (Pair aUser : aCapeType4) { - Logger.INFO("Adding Patreon cape for " + aUser.getKey()); - mPatreonCapes.add(aUser); - } - } - if (!aCapeType5.isEmpty()) { - for (Pair aUser : aCapeType5) { - Logger.INFO("Adding Dev cape for " + aUser.getKey()); - mDevCapes.add(aUser); - } - } - } - } else { - // No data decoded - } - } else { - // Nothing was cached? - } - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java deleted file mode 100644 index 0c9e59e2f2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java +++ /dev/null @@ -1,107 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.Tessellator; -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 net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.common.items.GT_VolumetricFlask; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import ic2.core.util.DrawUtil; - -@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) -public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { - - public GTPP_FlaskRenderer() { - MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); - MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); - } - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.FIRST_PERSON_MAP; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { - return type == ItemRenderType.ENTITY; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); - - int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; - IIcon icon = item.getIconIndex(); - GL11.glEnable(3042); - GL11.glEnable(3008); - if (type.equals(ItemRenderType.ENTITY)) { - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); - GL11.glTranslated(-0.5D, -0.6D, 0.0D); - } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { - GL11.glTranslated(1.0D, 1.0D, 0.0D); - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - } else if (type.equals(ItemRenderType.EQUIPPED)) { - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - GL11.glTranslated(-1.0D, -1.0D, 0.0D); - } - - FluidStack fs = cell.getFluid(item); - if (fs != null) { - IIcon iconWindow = cell.iconWindow; - IIcon fluidicon = fs.getFluid() - .getIcon(fs); - int fluidColor = fs.getFluid() - .getColor(fs); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(0, 1); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); - } else { - DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); - DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glBlendFunc(770, 771); - GL11.glDepthFunc(514); - GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); - } else { - DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); - DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); - } - - GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); - GL11.glDepthFunc(515); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); - } else { - ItemRenderer.renderItemIn2D( - Tessellator.instance, - icon.getMaxU(), - icon.getMinV(), - icon.getMinU(), - icon.getMaxV(), - icon.getIconWidth(), - icon.getIconHeight(), - 0.0625F); - } - GL11.glDisable(3008); - GL11.glDisable(3042); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java deleted file mode 100644 index bfd16b4cc5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java +++ /dev/null @@ -1,1250 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_SOUTH; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_UP; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_WEST; -import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_FOAM; -import static gregtech.api.interfaces.metatileentity.IConnectable.NO_CONNECTION; -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.UP; -import static net.minecraftforge.common.util.ForgeDirection.WEST; - -import java.util.EnumMap; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.registry.RenderingRegistry; -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.interfaces.tileentity.IPipeRenderedTileEntity; -import gregtech.api.interfaces.tileentity.ITexturedTileEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.render.GT_Renderer_Block; -import gtPlusPlus.xmod.gregtech.common.helpers.GT_MethodHelper; - -public class GTPP_Render_MachineBlock extends GT_Renderer_Block { - - public static GTPP_Render_MachineBlock INSTANCE; - public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); - - public GTPP_Render_MachineBlock() { - INSTANCE = this; - RenderingRegistry.registerBlockHandler(this); - } - - private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean active, boolean arg5) { - final IGregTechTileEntity gtTile = tile.getBaseMetaTileEntity(); - return tile.getTexture(gtTile, side, facing, (byte) colorIndex, active, arg5); - } - - private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, int facingMask, int colorIndex, - boolean active, boolean arg5) { - final MetaPipeEntity gtTile = (MetaPipeEntity) tile.getBaseMetaTileEntity(); - return gtTile.getTexture((IGregTechTileEntity) tile, side, facingMask, colorIndex, active, arg5); - } - - private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length) { - IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; - if (tMetaTileEntity != null) { - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity pipeRenderedTile) { - float tThickness = pipeRenderedTile.getThickNess(); - float sp = (1.0F - tThickness) / 2.0F; - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, DOWN, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, UP, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.NORTH, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.SOUTH, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.WEST, 0b001001, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.EAST, 0b001001, -1, true, false), - true); - Tessellator.instance.draw(); - } else { - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, DOWN, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, UP, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.NORTH, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.SOUTH, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.WEST, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.EAST, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - } - } - - public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - - return tTileEntity instanceof ITexturedTileEntity - ? renderStandardBlock( - aWorld, - aX, - aY, - aZ, - aBlock, - aRenderer, - new ITexture[][] { GT_MethodHelper.getTexture(tTileEntity, aBlock, DOWN), - GT_MethodHelper.getTexture(tTileEntity, aBlock, UP), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.NORTH), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.SOUTH), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.WEST), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.EAST) }) - : false; - } - - public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer, ITexture[][] aTextures) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.NORTH.ordinal()], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.SOUTH.ordinal()], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.WEST.ordinal()], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.EAST.ordinal()], true); - return true; - } - - public boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { - final int aConnections = aTileEntity.getConnections(); - if ((aConnections & HAS_FOAM) != 0) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float tThickness = aTileEntity.getThickNess(); - if (tThickness >= 0.99F) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float sp = (1.0F - tThickness) / 2.0F; - int connexionSidesBits = 0; - - for (int ordinalSide = 0; ordinalSide < 6; ++ordinalSide) { - if ((aConnections & 1 << ordinalSide) != 0) { - connexionSidesBits = connexionSidesBits | 1 << (ordinalSide + 2) % 6; - } - } - - final EnumSet coveredSides = EnumSet.noneOf(ForgeDirection.class); - - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (aTileEntity.getCoverIDAtSide(side) != 0) coveredSides.add(side); - } - - if (coveredSides.containsAll(EnumSet.of(DOWN, UP, NORTH, SOUTH, WEST, EAST))) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - final EnumMap texture = new EnumMap<>(ForgeDirection.class); - final EnumMap textureUncovered = new EnumMap<>(ForgeDirection.class); - - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - texture.put(side, GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, side)); - textureUncovered.put(side, aTileEntity.getTextureUncovered(side)); - } - - switch (connexionSidesBits) { - case NO_CONNECTION -> { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - case (CONNECTED_DOWN | CONNECTED_UP) -> { - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - } - case (CONNECTED_NORTH | CONNECTED_SOUTH) -> { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } - if (!coveredSides.contains(UP)) { - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } - } - case (CONNECTED_WEST | CONNECTED_EAST) -> { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } - } - default -> { - if ((connexionSidesBits & CONNECTED_DOWN) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } else { - aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } - } - if ((connexionSidesBits & CONNECTED_UP) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } else { - aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - } - if ((connexionSidesBits & CONNECTED_NORTH) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } else { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } - } - if ((connexionSidesBits & CONNECTED_SOUTH) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } else { - aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(UP)) { - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } - } - if ((connexionSidesBits & CONNECTED_WEST) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } else { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } - } - if ((connexionSidesBits & CONNECTED_EAST) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } else { - aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } - } - } - } - - if (coveredSides.contains(DOWN)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - } - - if (coveredSides.contains(UP)) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - } - - if (coveredSides.contains(NORTH)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - } - - if (coveredSides.contains(SOUTH)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - } - - if (coveredSides.contains(WEST)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (coveredSides.contains(EAST)) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - return true; - } - } - } - } - - public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - @Override - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - aMeta += 30400; - if (aBlock instanceof GT_Block_Machines) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length - && GregTech_API.METATILEENTITIES[aMeta] != null - && !GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { - renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); - } - } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, - RenderBlocks aRenderer) { - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity == null ? false - : (aTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() - .renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer) - ? true - : (aTileEntity instanceof IPipeRenderedTileEntity - ? renderPipeBlock( - aWorld, - aX, - aY, - aZ, - aBlock, - (IPipeRenderedTileEntity) aTileEntity, - aRenderer) - : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); - } - - @Override - public boolean shouldRender3DInInventory(int aModel) { - return true; - } - - @Override - public int getRenderId() { - return this.mRenderID; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java new file mode 100644 index 0000000000..7ce7002738 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java @@ -0,0 +1,1250 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_SOUTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_UP; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_WEST; +import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_FOAM; +import static gregtech.api.interfaces.metatileentity.IConnectable.NO_CONNECTION; +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.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +import java.util.EnumMap; +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.api.GregTechAPI; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.common.blocks.BlockMachines; +import gregtech.common.render.GTRendererBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.GTMethodHelper; + +public class MachineBlockRenderer extends GTRendererBlock { + + public static MachineBlockRenderer INSTANCE; + public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); + + public MachineBlockRenderer() { + INSTANCE = this; + RenderingRegistry.registerBlockHandler(this); + } + + private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean active, boolean arg5) { + final IGregTechTileEntity gtTile = tile.getBaseMetaTileEntity(); + return tile.getTexture(gtTile, side, facing, (byte) colorIndex, active, arg5); + } + + private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, int facingMask, int colorIndex, + boolean active, boolean arg5) { + final MetaPipeEntity gtTile = (MetaPipeEntity) tile.getBaseMetaTileEntity(); + return gtTile.getTexture((IGregTechTileEntity) tile, side, facingMask, colorIndex, active, arg5); + } + + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { + if (aMeta > 0 && aMeta < GregTechAPI.METATILEENTITIES.length) { + IMetaTileEntity tMetaTileEntity = GregTechAPI.METATILEENTITIES[aMeta]; + if (tMetaTileEntity != null) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity pipeRenderedTile) { + float tThickness = pipeRenderedTile.getThickNess(); + float sp = (1.0F - tThickness) / 2.0F; + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, DOWN, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, UP, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.NORTH, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.SOUTH, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.WEST, 0b001001, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.EAST, 0b001001, -1, true, false), + true); + Tessellator.instance.draw(); + } else { + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, DOWN, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, UP, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.NORTH, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.SOUTH, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.WEST, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.EAST, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + + return tTileEntity instanceof ITexturedTileEntity + ? renderStandardBlock( + aWorld, + aX, + aY, + aZ, + aBlock, + aRenderer, + new ITexture[][] { GTMethodHelper.getTexture(tTileEntity, aBlock, DOWN), + GTMethodHelper.getTexture(tTileEntity, aBlock, UP), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.NORTH), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.SOUTH), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.WEST), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.EAST) }) + : false; + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.NORTH.ordinal()], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.SOUTH.ordinal()], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.WEST.ordinal()], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.EAST.ordinal()], true); + return true; + } + + public boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { + final int aConnections = aTileEntity.getConnections(); + if ((aConnections & HAS_FOAM) != 0) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float tThickness = aTileEntity.getThickNess(); + if (tThickness >= 0.99F) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float sp = (1.0F - tThickness) / 2.0F; + int connexionSidesBits = 0; + + for (int ordinalSide = 0; ordinalSide < 6; ++ordinalSide) { + if ((aConnections & 1 << ordinalSide) != 0) { + connexionSidesBits = connexionSidesBits | 1 << (ordinalSide + 2) % 6; + } + } + + final EnumSet coveredSides = EnumSet.noneOf(ForgeDirection.class); + + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aTileEntity.getCoverIDAtSide(side) != 0) coveredSides.add(side); + } + + if (coveredSides.containsAll(EnumSet.of(DOWN, UP, NORTH, SOUTH, WEST, EAST))) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + final EnumMap texture = new EnumMap<>(ForgeDirection.class); + final EnumMap textureUncovered = new EnumMap<>(ForgeDirection.class); + + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + texture.put(side, GTMethodHelper.getTexture((TileEntity) aTileEntity, aBlock, side)); + textureUncovered.put(side, aTileEntity.getTextureUncovered(side)); + } + + switch (connexionSidesBits) { + case NO_CONNECTION -> { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + case (CONNECTED_DOWN | CONNECTED_UP) -> { + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + } + case (CONNECTED_NORTH | CONNECTED_SOUTH) -> { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } + if (!coveredSides.contains(UP)) { + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } + } + case (CONNECTED_WEST | CONNECTED_EAST) -> { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } + } + default -> { + if ((connexionSidesBits & CONNECTED_DOWN) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } else { + aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } + } + if ((connexionSidesBits & CONNECTED_UP) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } else { + aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + } + if ((connexionSidesBits & CONNECTED_NORTH) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } else { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } + } + if ((connexionSidesBits & CONNECTED_SOUTH) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } else { + aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(UP)) { + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } + } + if ((connexionSidesBits & CONNECTED_WEST) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } else { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } + } + if ((connexionSidesBits & CONNECTED_EAST) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } else { + aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } + } + } + } + + if (coveredSides.contains(DOWN)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + } + + if (coveredSides.contains(UP)) { + aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + } + + if (coveredSides.contains(NORTH)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + } + + if (coveredSides.contains(SOUTH)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + } + + if (coveredSides.contains(WEST)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (coveredSides.contains(EAST)) { + aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + return true; + } + } + } + } + + public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aMeta += 30400; + if (aBlock instanceof BlockMachines) { + if (aMeta > 0 && aMeta < GregTechAPI.METATILEENTITIES.length + && GregTechAPI.METATILEENTITIES[aMeta] != null + && !GregTechAPI.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + } + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, + RenderBlocks aRenderer) { + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return aTileEntity == null ? false + : (aTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() + .renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer) + ? true + : (aTileEntity instanceof IPipeRenderedTileEntity + ? renderPipeBlock( + aWorld, + aX, + aY, + aZ, + aBlock, + (IPipeRenderedTileEntity) aTileEntity, + aRenderer) + : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); + } + + @Override + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + @Override + public int getRenderId() { + return this.mRenderID; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java deleted file mode 100644 index c1ba23c3c7..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ElectricAutoWorkbench.java +++ /dev/null @@ -1,868 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.automation; - -import java.util.ArrayList; - -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.oredict.OreDictionary; - -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.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.SlotGroup; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.enums.Textures.BlockIcons; -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.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT_MetaTileEntity_ElectricAutoWorkbench extends GT_MetaTileEntity_BasicTank implements IAddGregtechLogo { - - public int mMode = 0, mCurrentSlot = 0, mThroughPut = 0, mTicksUntilNextUpdate = 20; - public boolean mLastCraftSuccessful = false; - protected String mLocalName; - - private static final int MAX_MODES = 10; - private static final int MAX_THROUGHPUT = 4; - - public GT_MetaTileEntity_ElectricAutoWorkbench(final int aID, final int aTier, final String aDescription) { - super( - aID, - "basicmachine.automation.autoworkbench.0" + aTier, - "Auto Workbench (" + GT_Values.VN[aTier] + ")", - aTier, - 30, - aDescription); - mLocalName = "Auto Workbench (" + GT_Values.VN[aTier] + ")"; - } - - public GT_MetaTileEntity_ElectricAutoWorkbench(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 30, aDescription, aTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex < 19; - } - - @Override - public boolean isFacingValid(ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(ForgeDirection side) { - return !isOutputFacing(side); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long maxEUInput() { - return GT_Values.V[mTier]; - } - - @Override - public long maxEUOutput() { - return mThroughPut % 2 == 0 ? GT_Values.V[mTier] : 0; - } - - @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return Math.max(2048L, GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier])); - } - - @Override - public int getSizeInventory() { - return 30; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_ElectricAutoWorkbench( - this.mName, - this.mTier, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mMode", mMode); - aNBT.setInteger("mThroughPut", mThroughPut); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mMode = aNBT.getInteger("mMode"); - mThroughPut = aNBT.getInteger("mThroughPut"); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return side != getBaseMetaTileEntity().getFrontFacing() && side != getBaseMetaTileEntity().getBackFacing(); - } - - private void switchMode() { - mInventory[28] = null; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() - && getBaseMetaTileEntity().getUniversalEnergyStored() >= (mMode == 5 || mMode == 6 ? 128 : 2048) - && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || --mTicksUntilNextUpdate < 1)) { - mTicksUntilNextUpdate = 32; - - for (byte i = 19; i < 28; i++) { - if (mInventory[i] != null && mInventory[i].isItemStackDamageable() - && mInventory[i].getItem() - .hasContainerItem(mInventory[i])) { - mInventory[i].setItemDamage(OreDictionary.WILDCARD_VALUE); - } - } - - if (mInventory[18] == null) { - for (byte i = 0; i < 18 && mFluid != null; i++) { - ItemStack tOutput = GT_Utility.fillFluidContainer(mFluid, mInventory[i], false, true); - if (tOutput != null) { - for (byte j = 0; j < 9; j++) { - if (mInventory[j] == null || (GT_Utility.areStacksEqual(tOutput, mInventory[j]) - && mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize())) { - mFluid.amount -= GT_Utility.getFluidForFilledItem(tOutput, true).amount - * tOutput.stackSize; - getBaseMetaTileEntity().decrStackSize(i, 1); - if (mInventory[j] == null) { - mInventory[j] = tOutput; - } else { - mInventory[j].stackSize++; - } - if (mFluid.amount <= 0) mFluid = null; - break; - } - } - } - } - - ItemStack[] tRecipe = new ItemStack[9]; - ItemStack tTempStack = null, tOutput = null; - - if (mInventory[17] != null && mThroughPut < 2 && mMode != 0) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[17]; - mInventory[17] = null; - } - } else { - if (!mLastCraftSuccessful) { - mCurrentSlot = (mCurrentSlot + 1) % 18; - for (int i = 0; i < 17 && mInventory[mCurrentSlot] == null; i++) - mCurrentSlot = (mCurrentSlot + 1) % 18; - } - switch (mMode) { - case 0 -> { - if (mInventory[mCurrentSlot] != null - && !isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2 && mCurrentSlot < 8) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - for (int i = 0; i < 9; i++) { - tRecipe[i] = mInventory[i + 19]; - if (tRecipe[i] != null) { - tRecipe[i] = GT_Utility.copy(tRecipe[i]); - tRecipe[i].stackSize = 1; - } - } - } - case 1 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - } else break; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - tRecipe[2] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - } else break; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 2 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 3 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 4 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 5 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tOutput = GT_OreDictUnificator.get(true, tTempStack); - if (tOutput != null && GT_Utility.areStacksEqual(tOutput, tTempStack)) tOutput = null; - if (tOutput == null) { - tRecipe[0] = null; - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 6 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } else if (OrePrefixes.dustSmall.contains(mInventory[mCurrentSlot])) { - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) - == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } else if (OrePrefixes.dustTiny.contains(mInventory[mCurrentSlot])) { - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) - == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } else { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 7 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) - || !OrePrefixes.nugget.contains(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - tRecipe[0] = tTempStack; - tRecipe[1] = tTempStack; - tRecipe[2] = tTempStack; - tRecipe[3] = tTempStack; - tRecipe[4] = tTempStack; - tRecipe[5] = tTempStack; - tRecipe[6] = tTempStack; - tRecipe[7] = tTempStack; - tRecipe[8] = tTempStack; - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - } - case 8 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) - || mInventory[mCurrentSlot].getItemDamage() <= 0 - || !mInventory[mCurrentSlot].getItem() - .isRepairable()) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - tTempStack = GT_Utility.copy(mInventory[mCurrentSlot]); - tTempStack.stackSize = 1; - for (int i = mCurrentSlot + 1; i < 18; i++) { - if (mInventory[i] != null && mInventory[i].getItem() == tTempStack.getItem() - && mInventory[mCurrentSlot].getItemDamage() + mInventory[i].getItemDamage() - > tTempStack.getMaxDamage()) { - tRecipe[0] = tTempStack; - tRecipe[1] = GT_Utility.copy(mInventory[i]); - if (GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) - == null) { - if (mInventory[18] == null) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - } - break; - } - } - } - case 9 -> { - if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { - if (mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mCurrentSlot]; - mInventory[mCurrentSlot] = null; - mTicksUntilNextUpdate = 1; - } - break; - } - for (byte i = 0, j = 0; i < 18 && j < 9 - && (j < 2 - || GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) - == null); i++) { - tRecipe[j] = mInventory[(mCurrentSlot + i) % 18]; - if (tRecipe[j] != null) { - tRecipe[j] = GT_Utility.copy(tRecipe[j]); - tRecipe[j].stackSize = 1; - j++; - } - } - if (tRecipe[1] == null) tRecipe[0] = null; - } - } - } - - if (tOutput == null) - tOutput = GT_ModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe); - - if (tOutput != null || mMode == 0) mInventory[28] = tOutput; - - if (tOutput == null) { - mLastCraftSuccessful = false; - } else { - if ((tTempStack = GT_OreDictUnificator.get(true, tOutput)) != null) { - tTempStack.stackSize = tOutput.stackSize; - tOutput = tTempStack; - } - - mInventory[28] = GT_Utility.copy(tOutput); - ArrayList tList = recipeContent(tRecipe), tContent = benchContent(); - if (tList.size() > 0 && tContent.size() > 0) { - - boolean success = (mMode == 6 || mMode == 7 || mInventory[17] == null); - for (byte i = 0; i < tList.size() && success; i++) { - success = false; - for (byte j = 0; j < tContent.size() && !success; j++) { - if (GT_Utility.areStacksEqual(tList.get(i), tContent.get(j))) { - if (tList.get(i).stackSize <= tContent.get(j).stackSize) { - success = true; - } - } - } - } - - if (success) { - mLastCraftSuccessful = true; - - for (byte i = 8; i > -1; i--) { - for (byte j = 17; j > -1; j--) { - if (tRecipe[i] != null && mInventory[j] != null) { - if (GT_Utility.areStacksEqual(tRecipe[i], mInventory[j])) { - ItemStack tStack = GT_Utility.getContainerItem(mInventory[j], true); - if (tStack != null) { - getBaseMetaTileEntity().decrStackSize(j, 1); - if (!tStack.isItemStackDamageable() - || tStack.getItemDamage() < tStack.getMaxDamage()) { - for (byte k = 9; k < 18; k++) { - if (mInventory[k] == null) { - mInventory[k] = GT_Utility.copy(tStack); - break; - } else if (GT_Utility.areStacksEqual(mInventory[k], tStack) - && mInventory[k].stackSize + tStack.stackSize - <= tStack.getMaxStackSize()) { - mInventory[k].stackSize += tStack.stackSize; - break; - } - } - } - } else { - getBaseMetaTileEntity().decrStackSize(j, 1); - } - break; - } - } - } - } - - mInventory[18] = GT_Utility.copy(tOutput); - getBaseMetaTileEntity() - .decreaseStoredEnergyUnits(mMode == 5 || mMode == 6 || mMode == 7 ? 128 : 2048, true); - mTicksUntilNextUpdate = 1; - } else { - mLastCraftSuccessful = false; - if (mInventory[mMode == 0 ? 8 : 17] != null && mInventory[18] == null && mThroughPut < 2) { - mInventory[18] = mInventory[mMode == 0 ? 8 : 17]; - mInventory[mMode == 0 ? 8 : 17] = null; - mTicksUntilNextUpdate = 1; - } - } - } - - if (mInventory[18] == null && mThroughPut < 2) { - for (byte i = 0; i < 8; i++) { - for (byte j = i; ++j < 9;) { - if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j]) - && mInventory[i].getMaxStackSize() > 8) { - mInventory[18] = mInventory[j]; - mInventory[j] = null; - mTicksUntilNextUpdate = 1; - break; - } - } - } - } - } - } - - if (mThroughPut < 2) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits( - GT_Utility.moveOneItemStack( - getBaseMetaTileEntity(), - getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()), - getBaseMetaTileEntity().getBackFacing(), - getBaseMetaTileEntity().getFrontFacing(), - null, - false, - (byte) 64, - (byte) 1, - (byte) 64, - (byte) 1) * 10, - true); - } - } - } - - private boolean isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(ItemStack aStack) { - if (aStack == null) return true; - for (byte i = 19; i < 28; i++) { - if (mInventory[i] != null) { - if (GT_Utility.areStacksEqual(mInventory[i], aStack)) return true; - if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(mInventory[i], true), aStack)) - return true; - } - } - return false; - } - - private ArrayList recipeContent(ItemStack[] tRecipe) { - ArrayList tList = new ArrayList<>(); - for (byte i = 0; i < 9; i++) { - if (tRecipe[i] != null) { - boolean temp = false; - for (ItemStack itemStack : tList) { - if (GT_Utility.areStacksEqual(tRecipe[i], itemStack)) { - itemStack.stackSize++; - temp = true; - break; - } - } - if (!temp) tList.add(GT_Utility.copy(1, tRecipe[i])); - } - } - return tList; - } - - private ArrayList benchContent() { - ArrayList tList = new ArrayList<>(); - for (byte i = 0; i < 18; i++) { - if (mInventory[i] != null) { - boolean temp = false; - for (byte j = 0; j < tList.size(); j++) { - if (GT_Utility.areStacksEqual(mInventory[i], mInventory[j])) { - tList.get(j).stackSize += mInventory[i].stackSize; - temp = true; - break; - } - } - if (!temp) tList.add(GT_Utility.copy(mInventory[i])); - } - } - return tList; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return mMode == 0 ? aIndex >= 10 : aIndex >= 18; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return mMode == 0 ? aIndex < 9 : aIndex < 18; - } - - /* - * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == - * aFacing) return 112; if (GT_Utility.getOppositeSide(aSide) == aFacing) return 113; return 114; } - */ - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public int getTankPressure() { - return -100; - } - - @Override - public String[] getDescription() { - return new String[] { "Automatic Crafting Table Mk III", - // this.mDescription, - CORE.GT_Tooltip.get() }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getBack(i); - rTextures[7][i + 1] = this.getBottom(i); - rTextures[8][i + 1] = this.getTop(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return this.mTextures[0][aColorIndex + 1]; - } else if (side.getOpposite() == facing) { - return this.mTextures[1][aColorIndex + 1]; - } else { - return this.mTextures[4][aColorIndex + 1]; - } - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; - } - - @Override - public void addGregTechLogo(ModularWindow.Builder builder) { - builder.widget( - new DrawableWidget().setDrawable(getGUITextureSet().getGregTechLogo()) - .setSize(17, 17) - .setPos(118, 22)); - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 3) - .endAtSlot(8) - .build() - .setPos(7, 4)) - .widget( - SlotGroup.ofItemHandler(inventoryHandler, 9) - .startFromSlot(9) - .endAtSlot(17) - .canInsert(false) - .background(GT_UITextures.SLOT_DARK_GRAY) - .applyForWidget(SlotWidget::disableShiftInsert) - .build() - .setPos(7, 59)) - .widget( - new SlotWidget(inventoryHandler, 18).setAccess(true, false) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_OUT) - .setPos(151, 40)) - .widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SLOTS_HOLO_3BY3) - .setPos(62, 4) - .setSize(54, 54)) - .widget( - SlotGroup.ofItemHandler(inventoryHandler, 3) - .startFromSlot(19) - .endAtSlot(27) - .phantom(true) - .background(GT_UITextures.TRANSPARENT) - .build() - .setPos(62, 4)) - .widget( - SlotWidget.phantom(inventoryHandler, 28) - .disableInteraction() - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_ARROW_4) - .setPos(151, 4)); - builder.widget( - new CycleButtonWidget().setGetter(() -> mThroughPut) - .setSetter(val -> mThroughPut = val) - .setLength(MAX_THROUGHPUT) - .setTextureGetter(i -> GTPP_UITextures.OVERLAY_BUTTON_THROUGHPUT[i]) - .setBackground(GT_UITextures.BUTTON_STANDARD) - .setPos(120, 4) - .setSize(18, 18)); - String[] mModeText = new String[] { "Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", - "???", "Hammer?", "Circle" }; - CycleButtonWidget modeButton = new CycleButtonWidget().setGetter(() -> mMode) - .setSetter(val -> { - mMode = val; - switchMode(); - }) - .setLength(MAX_MODES) - .setTextureGetter(i -> GTPP_UITextures.OVERLAY_BUTTON_MODE[i]); - for (int i = 0; i < MAX_MODES; i++) { - modeButton.addTooltip(i, "Mode: " + mModeText[i]); - } - builder.widget( - modeButton.setBackground(GT_UITextures.BUTTON_STANDARD) - .setPos(120, 40) - .setSize(18, 18)); - builder.widget( - new DrawableWidget().setDrawable(GTPP_UITextures.PICTURE_WORKBENCH_CIRCLE) - .setPos(136, 23) - .setSize(16, 16)) - .widget( - new DrawableWidget().setDrawable(GTPP_UITextures.PICTURE_ARROW_WHITE_DOWN) - .setPos(155, 23) - .setSize(10, 16)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java deleted file mode 100644 index 33dbfee6d4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java +++ /dev/null @@ -1,833 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.automation; - -import static gtPlusPlus.core.lib.CORE.sTesseractGeneratorOwnershipMap; -import static gtPlusPlus.core.lib.CORE.sTesseractTerminalOwnershipMap; - -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IDigitalChest; -import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; - -public class GT_MetaTileEntity_TesseractGenerator extends GT_MetaTileEntity_BasicTank { - - public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; - public static int TESSERACT_ENERGY_COST = 128; - public byte isWorking = 0; - public int oFrequency = 0; - public int mNeededEnergy = 0; - public int mFrequency = 0; - public UUID mOwner; - - public GT_MetaTileEntity_TesseractGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, ""); - } - - public GT_MetaTileEntity_TesseractGenerator(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return true; - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getBackFacing(); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return this.getBaseMetaTileEntity() - .getEUCapacity() / 2; - } - - @Override - public long maxEUInput() { - return 512; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxEUStore() { - return 512 * 32; - } - - @Override - public long maxSteamStore() { - return this.maxEUStore(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean ownerControl() { - return true; - } - - @Override - public int getProgresstime() { - return (TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency) - == this) && (this.isWorking >= 20) ? 999 : 0; - } - - @Override - public int maxProgresstime() { - return 1000; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); - if (mOwner != null) aNBT.setString("mOwner", mOwner.toString()); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); - try { - this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); - } catch (IllegalArgumentException i) { - - } - } - - @Override - public void onConfigLoad() { - int J = 4; - TESSERACT_ENERGY_COST = 128 * J; - TESSERACT_ENERGY_COST_DIMENSIONAL = 512 * J; - } - - @Override - public void onServerStart() { - sTesseractGeneratorOwnershipMap.clear(); - sTesseractTerminalOwnershipMap.clear(); - } - - public void onServerStop() { - sTesseractGeneratorOwnershipMap.clear(); - sTesseractTerminalOwnershipMap.clear(); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final ForgeDirection side, final float aX, final float aY, final float aZ) { - - if (this.mOwner == null) { - if (this.getBaseMetaTileEntity() - .getOwnerName() != null - && !this.getBaseMetaTileEntity() - .getOwnerName() - .equals("")) { - if (this.getBaseMetaTileEntity() - .getOwnerName() - .toLowerCase() - .equals( - aPlayer.getDisplayName() - .toLowerCase())) { - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - } - } - } - - if (side == this.getBaseMetaTileEntity() - .getFrontFacing()) { - if (aPlayer.getUniqueID() - .compareTo(this.mOwner) == 0) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - Logger.WARNING("Freq. -1 | " + this.mFrequency); - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 1; - - break; - case 1: - Logger.WARNING("Freq. +1 | " + this.mFrequency); - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 1; - default: - // Utils.LOG_WARNING("Did not click the correct place."); - break; - } - if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { - GT_Utility.sendChatToPlayer( - aPlayer, - "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); - } - } else if (aPlayer.getUniqueID() - .compareTo(this.mOwner) != 0) { - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); - } - } - - return true; - } - - @Override - public void onScrewdriverRightClick(final ForgeDirection side, final EntityPlayer aPlayer, final float aX, - final float aY, final float aZ) { - if (aPlayer.getUniqueID() - .compareTo(this.mOwner) == 0) { - if (side == this.getBaseMetaTileEntity() - .getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0 -> { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 64; - } - case 1 -> { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 64; - } - case 2 -> { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 512; - } - case 3 -> { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 512; - } - } - if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { - GT_Utility.sendChatToPlayer( - aPlayer, - "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); - } - } - } else { - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); - } - } - - public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public String[] getInfoData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) - && ((tTileEntity instanceof IGregTechDeviceInformation)) - && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) { - return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); - } - return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, - (getGeneratorEntity() == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - public boolean isSendingInformation() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation))) { - return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); - } - return false; - } - - @Override - public boolean isDigitalChest() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).isDigitalChest(); - } - return false; - } - - @Override - public ItemStack[] getStoredItemData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).getStoredItemData(); - } - return new ItemStack[] {}; - } - - @Override - public void setItemCount(final int aCount) { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - ((IDigitalChest) tTileEntity).setItemCount(aCount); - } - } - - @Override - public int getMaxItemCount() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest) tTileEntity).getMaxItemCount(); - } - return 0; - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.isItemValidForSlot(aIndex, aStack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int ordinalSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return new int[0]; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(ordinalSide); - } - final int[] rArray = new int[this.getSizeInventory()]; - for (int i = 0; i < this.getSizeInventory(); i++) { - rArray[i] = i; - } - return rArray; - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, ordinalSide); - } - return true; - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - if ((tTileEntity instanceof ISidedInventory)) { - return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, ordinalSide); - } - return true; - } - - @Override - public int getSizeInventory() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.getStackInSlot(aIndex); - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); - } - - @Override - public String getInventoryName() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); - } - - @Override - public int getInventoryStackLimit() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return new FluidTankInfo[0]; - } - return tTileEntity.getTankInfo(aSide); - } - - @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); - } - - @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide( - this.getBaseMetaTileEntity() - .getBackFacing()); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); - } - - public boolean addEnergyConsumption(final GT_MetaTileEntity_TesseractTerminal aTerminal) { - if (!this.getBaseMetaTileEntity() - .isAllowedToWork()) { - return false; - } - int J = (aTerminal.getBaseMetaTileEntity() - .getWorld() - == this.getBaseMetaTileEntity() - .getWorld() ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); - - J *= 4; - - this.mNeededEnergy += J; - - return true; - } - - public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { - return (this.getBaseMetaTileEntity() != null) && (!this.getBaseMetaTileEntity() - .isInvalidTileEntity()) - && (this.getBaseMetaTileEntity() - .isAllowedToWork()) - && ((aOwnerName == null) || (this.getBaseMetaTileEntity() - .getOwnerName() - .equals(aOwnerName))) - && ((aWorkIrrelevant) || (this.isWorking >= 20)); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // TODO Auto-generated method stub - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - // Utils.LOG_WARNING("Ticking Generator. 0"); - if (this.getBaseMetaTileEntity() - .isServerSide()) { - // Utils.LOG_WARNING("Ticking Generator."); - // Set owner - if (PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()) - != null) { - if (this.mOwner == null) { - Logger.WARNING("Setting Generators Owner. 1"); - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - } - } - - if (this.mFrequency != this.oFrequency) { - - Logger.WARNING("mFreq != oFreq"); - - if (getGeneratorEntity() == this) { - getGeneratorEntity(this.oFrequency); - this.getBaseMetaTileEntity() - .issueBlockUpdate(); - Logger.WARNING("this Gen == oFreq on map - do block update"); - } - Logger.WARNING("mFreq will be set to oFreq"); - this.oFrequency = this.mFrequency; - } - if ((this.getBaseMetaTileEntity() - .isAllowedToWork()) - && (this.getBaseMetaTileEntity() - .decreaseStoredEnergyUnits(this.mNeededEnergy, false))) { - // Utils.LOG_WARNING("Can Work & Has Energy"); - if ((getGeneratorEntity(Integer.valueOf(this.mFrequency)) == null) - || (!getGeneratorEntity(Integer.valueOf(this.mFrequency)).isValidTesseractGenerator(null, true))) { - // Utils.LOG_WARNING("storing TE I think to mFreq map?"); - TesseractHelper.setGeneratorOwnershipByPlayer( - PlayerUtils.getPlayerOnServerFromUUID(mOwner), - this.mFrequency, - this); - } - } else { - if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { - Logger.WARNING("this gen == mFreq on map - do block update"); - TesseractHelper.removeGenerator(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); - this.getBaseMetaTileEntity() - .issueBlockUpdate(); - } - this.isWorking = 0; - } - if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { - // Utils.LOG_WARNING("mFreq == this - do work related things"); - if (this.isWorking < 20) { - this.isWorking = ((byte) (this.isWorking + 1)); - } - if (this.isWorking == 20) { - this.getBaseMetaTileEntity() - .issueBlockUpdate(); - this.isWorking = ((byte) (this.isWorking + 1)); - } - } else { - this.isWorking = 0; - } - this.mNeededEnergy = 0; - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "Generates a Tesseract for the attached Inventory", - "Connect with pipes to insert items", - "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", - "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", - CORE.GT_Tooltip.get()); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return side == facing - ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - // To-Do? - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity() { - GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); - if (thisGenerator != null) { - return thisGenerator; - } - return null; - } - - private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity(int frequency) { - GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), frequency); - if (thisGenerator != null) { - return thisGenerator; - } - return null; - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity() - .getOwnerName() != null - && !this.getBaseMetaTileEntity() - .getOwnerName() - .equals("")) { - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - Logger.WARNING("Setting Generators Owner. 2"); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public void onRemoval() { - try { - CORE.sTesseractGeneratorOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - super.onRemoval(); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java deleted file mode 100644 index 28b567e06c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ /dev/null @@ -1,643 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.automation; - -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import org.apache.commons.lang3.ArrayUtils; - -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_BasicTank; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; - -public class GT_MetaTileEntity_TesseractTerminal extends GT_MetaTileEntity_BasicTank { - - public int mFrequency = 0; - public UUID mOwner; - public boolean mDidWork = false; - public static boolean sInterDimensionalTesseractAllowed = true; - private static int TESSERACT_ENERGY_COST = 128; - private static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; - - public GT_MetaTileEntity_TesseractTerminal(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, ""); - } - - public GT_MetaTileEntity_TesseractTerminal(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getBackFacing(); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return (this.getBaseMetaTileEntity() - .getEUCapacity() / 100); - } - - @Override - public long maxEUInput() { - return TESSERACT_ENERGY_COST_DIMENSIONAL; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUStore() { - return TESSERACT_ENERGY_COST_DIMENSIONAL * 8 * 32; - } - - @Override - public long maxSteamStore() { - return this.maxEUStore(); - } - - @Override - public boolean ownerControl() { - return true; - } - - @Override - public int getProgresstime() { - return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; - } - - @Override - public int maxProgresstime() { - return 1000; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); - aNBT.setString("mOwner", mOwner.toString()); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); - this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); - } - - @Override - public void onConfigLoad() { - sInterDimensionalTesseractAllowed = true; - TESSERACT_ENERGY_COST = 512; - TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final ForgeDirection side, final float aX, final float aY, final float aZ) { - - if (this.mOwner == null) { - if (this.getBaseMetaTileEntity() - .getOwnerName() != null - && !this.getBaseMetaTileEntity() - .getOwnerName() - .equals("")) { - if (this.getBaseMetaTileEntity() - .getOwnerName() - .toLowerCase() - .equals( - aPlayer.getDisplayName() - .toLowerCase())) { - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - } - } - } - - if (aPlayer.getUniqueID() - .compareTo(this.mOwner) == 0) { - if (side == this.getBaseMetaTileEntity() - .getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0: - // Utils.LOG_WARNING("Freq. -1 | " + this.mFrequency); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 1; - break; - case 1: - // Utils.LOG_WARNING("Freq. +1 | " + this.mFrequency); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 1; - default: - // Utils.LOG_WARNING("Did not click the correct place."); - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - break; - } - PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - if (this.getTesseract(this.mFrequency, false) != null) { - PlayerUtils.messagePlayer( - aPlayer, - new StringBuilder().append(EnumChatFormatting.GREEN) - .append(" (Connected)") - .toString()); - } - } - } else if (aPlayer.getUniqueID() - .compareTo(this.mOwner) != 0) { - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); - } - return true; - } - - @Override - public void onScrewdriverRightClick(final ForgeDirection side, final EntityPlayer aPlayer, final float aX, - final float aY, final float aZ) { - if (aPlayer.getUniqueID() - .compareTo(this.mOwner) == 0) { - if (side == this.getBaseMetaTileEntity() - .getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0 -> { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 64; - } - case 1 -> { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 64; - } - case 2 -> { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency -= 512; - } - case 3 -> { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - this.mFrequency += 512; - } - } - GT_Utility.sendChatToPlayer( - aPlayer, - "Frequency: " + this.mFrequency - + (this.getTesseract(this.mFrequency, false) == null ? "" - : new StringBuilder().append(EnumChatFormatting.GREEN) - .append(" (Connected)") - .toString())); - } - } else if (aPlayer.getUniqueID() - .compareTo(this.mOwner) != 0) { - GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); - } - } - - public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - public GT_MetaTileEntity_TesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { - final GT_MetaTileEntity_TesseractGenerator rTesseract = TesseractHelper - .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), aFrequency); - if (rTesseract == null) { - return null; - } - if (!TesseractHelper.isGeneratorOwnedByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), rTesseract)) { - return null; - } - if (rTesseract.mFrequency != aFrequency) { - TesseractHelper.setTerminalOwnershipByPlayer( - PlayerUtils.getPlayerOnServerFromUUID(mOwner), - Integer.valueOf(aFrequency), - null); - return null; - } - if (!rTesseract.isValidTesseractGenerator( - this.getBaseMetaTileEntity() - .getOwnerName(), - aWorkIrrelevant)) { - return null; - } - if ((!sInterDimensionalTesseractAllowed) && (rTesseract.getBaseMetaTileEntity() - .getWorld() - != this.getBaseMetaTileEntity() - .getWorld())) { - return null; - } - return rTesseract; - } - - @Override - public String[] getInfoData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity != null) && (this.getBaseMetaTileEntity() - .isAllowedToWork()) && (tTileEntity.isSendingInformation())) { - return tTileEntity.getInfoData(); - } - return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, - this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isDigitalChest() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.isDigitalChest(); - } - - @Override - public ItemStack[] getStoredItemData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.getStoredItemData(); - } - - @Override - public void setItemCount(final int aCount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return; - } - tTileEntity.setItemCount(aCount); - } - - @Override - public int getMaxItemCount() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.getMaxItemCount(); - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.isItemValidForSlot(aIndex, aStack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int ordinalSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return new int[0]; - } - return tTileEntity.getAccessibleSlotsFromSide(ordinalSide); - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canInsertItem(aIndex, aStack, ordinalSide); - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canExtractItem(aIndex, aStack, ordinalSide); - } - - @Override - public int getSizeInventory() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.getStackInSlot(aIndex); - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); - } - - @Override - public String getInventoryName() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); - } - - @Override - public int getInventoryStackLimit() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return new FluidTankInfo[0]; - } - return tTileEntity.getTankInfo(aSide); - } - - @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); - } - - @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() - .isAllowedToWork())) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((this.getBaseMetaTileEntity() - .isServerSide()) - && (this.getBaseMetaTileEntity() - .isAllowedToWork())) { - // Set owner - if (PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()) - != null) { - if (this.mOwner == null) { - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - } - } - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); - if (tTileEntity != null) { - tTileEntity.addEnergyConsumption(this); - if ((!this.mDidWork) && (this.getTesseract(this.mFrequency, false) != null)) { - this.mDidWork = true; - this.getBaseMetaTileEntity() - .issueBlockUpdate(); - this.getBaseMetaTileEntity() - .decreaseStoredEnergyUnits(128, false); - } - } else if (this.mDidWork == true) { - this.mDidWork = false; - this.getBaseMetaTileEntity() - .issueBlockUpdate(); - } - } - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "Accesses Tesseract Generators remotely", - "Connect with pipes to extract items or fluids", - "Outputs from the back face", - "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", - "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", - CORE.GT_Tooltip.get()); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return side == facing - ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - // To-Do? - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity() - .getOwnerName() != null - && !this.getBaseMetaTileEntity() - .getOwnerName() - .equals("")) { - this.mOwner = PlayerUtils.getPlayersUUIDByName( - this.getBaseMetaTileEntity() - .getOwnerName()); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public void onRemoval() { - try { - CORE.sTesseractTerminalOwnershipMap.get(mOwner) - .remove(this.mFrequency); - } catch (Throwable t) {} - super.onRemoval(); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTEElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTEElectricAutoWorkbench.java new file mode 100644 index 0000000000..05150c8478 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTEElectricAutoWorkbench.java @@ -0,0 +1,864 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import java.util.ArrayList; + +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.oredict.OreDictionary; + +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.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +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.MTEBasicTank; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEElectricAutoWorkbench extends MTEBasicTank implements IAddGregtechLogo { + + public int mMode = 0, mCurrentSlot = 0, mThroughPut = 0, mTicksUntilNextUpdate = 20; + public boolean mLastCraftSuccessful = false; + protected String mLocalName; + + private static final int MAX_MODES = 10; + private static final int MAX_THROUGHPUT = 4; + + public MTEElectricAutoWorkbench(final int aID, final int aTier, final String aDescription) { + super( + aID, + "basicmachine.automation.autoworkbench.0" + aTier, + "Auto Workbench (" + GTValues.VN[aTier] + ")", + aTier, + 30, + aDescription); + mLocalName = "Auto Workbench (" + GTValues.VN[aTier] + ")"; + } + + public MTEElectricAutoWorkbench(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 30, aDescription, aTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 19; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return !isOutputFacing(side); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long maxEUInput() { + return GTValues.V[mTier]; + } + + @Override + public long maxEUOutput() { + return mThroughPut % 2 == 0 ? GTValues.V[mTier] : 0; + } + + @Override + public long getMinimumStoredEU() { + return GTValues.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return Math.max(2048L, GTValues.V[this.mTier] * (this.mTier * GTValues.V[this.mTier])); + } + + @Override + public int getSizeInventory() { + return 30; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEElectricAutoWorkbench(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mMode", mMode); + aNBT.setInteger("mThroughPut", mThroughPut); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mMode = aNBT.getInteger("mMode"); + mThroughPut = aNBT.getInteger("mThroughPut"); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aStack) { + return side != getBaseMetaTileEntity().getFrontFacing() && side != getBaseMetaTileEntity().getBackFacing(); + } + + private void switchMode() { + mInventory[28] = null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide() + && getBaseMetaTileEntity().getUniversalEnergyStored() >= (mMode == 5 || mMode == 6 ? 128 : 2048) + && (getBaseMetaTileEntity().hasWorkJustBeenEnabled() || --mTicksUntilNextUpdate < 1)) { + mTicksUntilNextUpdate = 32; + + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null && mInventory[i].isItemStackDamageable() + && mInventory[i].getItem() + .hasContainerItem(mInventory[i])) { + mInventory[i].setItemDamage(OreDictionary.WILDCARD_VALUE); + } + } + + if (mInventory[18] == null) { + for (byte i = 0; i < 18 && mFluid != null; i++) { + ItemStack tOutput = GTUtility.fillFluidContainer(mFluid, mInventory[i], false, true); + if (tOutput != null) { + for (byte j = 0; j < 9; j++) { + if (mInventory[j] == null || (GTUtility.areStacksEqual(tOutput, mInventory[j]) + && mInventory[j].stackSize + tOutput.stackSize <= tOutput.getMaxStackSize())) { + mFluid.amount -= GTUtility.getFluidForFilledItem(tOutput, true).amount + * tOutput.stackSize; + getBaseMetaTileEntity().decrStackSize(i, 1); + if (mInventory[j] == null) { + mInventory[j] = tOutput; + } else { + mInventory[j].stackSize++; + } + if (mFluid.amount <= 0) mFluid = null; + break; + } + } + } + } + + ItemStack[] tRecipe = new ItemStack[9]; + ItemStack tTempStack = null, tOutput = null; + + if (mInventory[17] != null && mThroughPut < 2 && mMode != 0) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[17]; + mInventory[17] = null; + } + } else { + if (!mLastCraftSuccessful) { + mCurrentSlot = (mCurrentSlot + 1) % 18; + for (int i = 0; i < 17 && mInventory[mCurrentSlot] == null; i++) + mCurrentSlot = (mCurrentSlot + 1) % 18; + } + switch (mMode) { + case 0 -> { + if (mInventory[mCurrentSlot] != null + && !isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2 && mCurrentSlot < 8) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (int i = 0; i < 9; i++) { + tRecipe[i] = mInventory[i + 19]; + if (tRecipe[i] != null) { + tRecipe[i] = GTUtility.copy(tRecipe[i]); + tRecipe[i].stackSize = 1; + } + } + } + case 1 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + } else break; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + tRecipe[2] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + } else break; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 2 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 3 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 4 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 5 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tOutput = GTOreDictUnificator.get(true, tTempStack); + if (tOutput != null && GTUtility.areStacksEqual(tOutput, tTempStack)) tOutput = null; + if (tOutput == null) { + tRecipe[0] = null; + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 6 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } else if (OrePrefixes.dustSmall.contains(mInventory[mCurrentSlot])) { + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } else if (OrePrefixes.dustTiny.contains(mInventory[mCurrentSlot])) { + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } else { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 7 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) + || !OrePrefixes.nugget.contains(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + tRecipe[0] = tTempStack; + tRecipe[1] = tTempStack; + tRecipe[2] = tTempStack; + tRecipe[3] = tTempStack; + tRecipe[4] = tTempStack; + tRecipe[5] = tTempStack; + tRecipe[6] = tTempStack; + tRecipe[7] = tTempStack; + tRecipe[8] = tTempStack; + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + } + case 8 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot]) + || mInventory[mCurrentSlot].getItemDamage() <= 0 + || !mInventory[mCurrentSlot].getItem() + .isRepairable()) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + tTempStack = GTUtility.copy(mInventory[mCurrentSlot]); + tTempStack.stackSize = 1; + for (int i = mCurrentSlot + 1; i < 18; i++) { + if (mInventory[i] != null && mInventory[i].getItem() == tTempStack.getItem() + && mInventory[mCurrentSlot].getItemDamage() + mInventory[i].getItemDamage() + > tTempStack.getMaxDamage()) { + tRecipe[0] = tTempStack; + tRecipe[1] = GTUtility.copy(mInventory[i]); + if (GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) + == null) { + if (mInventory[18] == null) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + } + break; + } + } + } + case 9 -> { + if (isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(mInventory[mCurrentSlot])) { + if (mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mCurrentSlot]; + mInventory[mCurrentSlot] = null; + mTicksUntilNextUpdate = 1; + } + break; + } + for (byte i = 0, j = 0; i < 18 && j < 9 + && (j < 2 + || GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe) + == null); i++) { + tRecipe[j] = mInventory[(mCurrentSlot + i) % 18]; + if (tRecipe[j] != null) { + tRecipe[j] = GTUtility.copy(tRecipe[j]); + tRecipe[j].stackSize = 1; + j++; + } + } + if (tRecipe[1] == null) tRecipe[0] = null; + } + } + } + + if (tOutput == null) + tOutput = GTModHandler.getAllRecipeOutput(getBaseMetaTileEntity().getWorld(), tRecipe); + + if (tOutput != null || mMode == 0) mInventory[28] = tOutput; + + if (tOutput == null) { + mLastCraftSuccessful = false; + } else { + if ((tTempStack = GTOreDictUnificator.get(true, tOutput)) != null) { + tTempStack.stackSize = tOutput.stackSize; + tOutput = tTempStack; + } + + mInventory[28] = GTUtility.copy(tOutput); + ArrayList tList = recipeContent(tRecipe), tContent = benchContent(); + if (tList.size() > 0 && tContent.size() > 0) { + + boolean success = (mMode == 6 || mMode == 7 || mInventory[17] == null); + for (byte i = 0; i < tList.size() && success; i++) { + success = false; + for (byte j = 0; j < tContent.size() && !success; j++) { + if (GTUtility.areStacksEqual(tList.get(i), tContent.get(j))) { + if (tList.get(i).stackSize <= tContent.get(j).stackSize) { + success = true; + } + } + } + } + + if (success) { + mLastCraftSuccessful = true; + + for (byte i = 8; i > -1; i--) { + for (byte j = 17; j > -1; j--) { + if (tRecipe[i] != null && mInventory[j] != null) { + if (GTUtility.areStacksEqual(tRecipe[i], mInventory[j])) { + ItemStack tStack = GTUtility.getContainerItem(mInventory[j], true); + if (tStack != null) { + getBaseMetaTileEntity().decrStackSize(j, 1); + if (!tStack.isItemStackDamageable() + || tStack.getItemDamage() < tStack.getMaxDamage()) { + for (byte k = 9; k < 18; k++) { + if (mInventory[k] == null) { + mInventory[k] = GTUtility.copy(tStack); + break; + } else if (GTUtility.areStacksEqual(mInventory[k], tStack) + && mInventory[k].stackSize + tStack.stackSize + <= tStack.getMaxStackSize()) { + mInventory[k].stackSize += tStack.stackSize; + break; + } + } + } + } else { + getBaseMetaTileEntity().decrStackSize(j, 1); + } + break; + } + } + } + } + + mInventory[18] = GTUtility.copy(tOutput); + getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(mMode == 5 || mMode == 6 || mMode == 7 ? 128 : 2048, true); + mTicksUntilNextUpdate = 1; + } else { + mLastCraftSuccessful = false; + if (mInventory[mMode == 0 ? 8 : 17] != null && mInventory[18] == null && mThroughPut < 2) { + mInventory[18] = mInventory[mMode == 0 ? 8 : 17]; + mInventory[mMode == 0 ? 8 : 17] = null; + mTicksUntilNextUpdate = 1; + } + } + } + + if (mInventory[18] == null && mThroughPut < 2) { + for (byte i = 0; i < 8; i++) { + for (byte j = i; ++j < 9;) { + if (GTUtility.areStacksEqual(mInventory[i], mInventory[j]) + && mInventory[i].getMaxStackSize() > 8) { + mInventory[18] = mInventory[j]; + mInventory[j] = null; + mTicksUntilNextUpdate = 1; + break; + } + } + } + } + } + } + + if (mThroughPut < 2) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits( + GTUtility.moveOneItemStack( + getBaseMetaTileEntity(), + getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()), + getBaseMetaTileEntity().getBackFacing(), + getBaseMetaTileEntity().getFrontFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1) * 10, + true); + } + } + } + + private boolean isItemTypeOrItsEmptyLiquidContainerInCraftingGrid(ItemStack aStack) { + if (aStack == null) return true; + for (byte i = 19; i < 28; i++) { + if (mInventory[i] != null) { + if (GTUtility.areStacksEqual(mInventory[i], aStack)) return true; + if (GTUtility.areStacksEqual(GTUtility.getContainerForFilledItem(mInventory[i], true), aStack)) + return true; + } + } + return false; + } + + private ArrayList recipeContent(ItemStack[] tRecipe) { + ArrayList tList = new ArrayList<>(); + for (byte i = 0; i < 9; i++) { + if (tRecipe[i] != null) { + boolean temp = false; + for (ItemStack itemStack : tList) { + if (GTUtility.areStacksEqual(tRecipe[i], itemStack)) { + itemStack.stackSize++; + temp = true; + break; + } + } + if (!temp) tList.add(GTUtility.copy(1, tRecipe[i])); + } + } + return tList; + } + + private ArrayList benchContent() { + ArrayList tList = new ArrayList<>(); + for (byte i = 0; i < 18; i++) { + if (mInventory[i] != null) { + boolean temp = false; + for (byte j = 0; j < tList.size(); j++) { + if (GTUtility.areStacksEqual(mInventory[i], mInventory[j])) { + tList.get(j).stackSize += mInventory[i].stackSize; + temp = true; + break; + } + } + if (!temp) tList.add(GTUtility.copy(mInventory[i])); + } + } + return tList; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return mMode == 0 ? aIndex >= 10 : aIndex >= 18; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return mMode == 0 ? aIndex < 9 : aIndex < 18; + } + + /* + * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == + * aFacing) return 112; if (GT_Utility.getOppositeSide(aSide) == aFacing) return 113; return 114; } + */ + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public String[] getDescription() { + return new String[] { "Automatic Crafting Table Mk III", + // this.mDescription, + GTPPCore.GT_Tooltip.get() }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return this.mTextures[0][aColorIndex + 1]; + } else if (side.getOpposite() == facing) { + return this.mTextures[1][aColorIndex + 1]; + } else { + return this.mTextures[4][aColorIndex + 1]; + } + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(BlockIcons.OVERLAY_PIPE) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Adv_Workbench_Crafting_Overlay) }; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(getGUITextureSet().getGregTechLogo()) + .setSize(17, 17) + .setPos(118, 22)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 3) + .endAtSlot(8) + .build() + .setPos(7, 4)) + .widget( + SlotGroup.ofItemHandler(inventoryHandler, 9) + .startFromSlot(9) + .endAtSlot(17) + .canInsert(false) + .background(GTUITextures.SLOT_DARK_GRAY) + .applyForWidget(SlotWidget::disableShiftInsert) + .build() + .setPos(7, 59)) + .widget( + new SlotWidget(inventoryHandler, 18).setAccess(true, false) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_OUT) + .setPos(151, 40)) + .widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SLOTS_HOLO_3BY3) + .setPos(62, 4) + .setSize(54, 54)) + .widget( + SlotGroup.ofItemHandler(inventoryHandler, 3) + .startFromSlot(19) + .endAtSlot(27) + .phantom(true) + .background(GTUITextures.TRANSPARENT) + .build() + .setPos(62, 4)) + .widget( + SlotWidget.phantom(inventoryHandler, 28) + .disableInteraction() + .setBackground(getGUITextureSet().getItemSlot(), GTPPUITextures.OVERLAY_SLOT_ARROW_4) + .setPos(151, 4)); + builder.widget( + new CycleButtonWidget().setGetter(() -> mThroughPut) + .setSetter(val -> mThroughPut = val) + .setLength(MAX_THROUGHPUT) + .setTextureGetter(i -> GTPPUITextures.OVERLAY_BUTTON_THROUGHPUT[i]) + .setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(120, 4) + .setSize(18, 18)); + String[] mModeText = new String[] { "Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", + "???", "Hammer?", "Circle" }; + CycleButtonWidget modeButton = new CycleButtonWidget().setGetter(() -> mMode) + .setSetter(val -> { + mMode = val; + switchMode(); + }) + .setLength(MAX_MODES) + .setTextureGetter(i -> GTPPUITextures.OVERLAY_BUTTON_MODE[i]); + for (int i = 0; i < MAX_MODES; i++) { + modeButton.addTooltip(i, "Mode: " + mModeText[i]); + } + builder.widget( + modeButton.setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(120, 40) + .setSize(18, 18)); + builder.widget( + new DrawableWidget().setDrawable(GTPPUITextures.PICTURE_WORKBENCH_CIRCLE) + .setPos(136, 23) + .setSize(16, 16)) + .widget( + new DrawableWidget().setDrawable(GTPPUITextures.PICTURE_ARROW_WHITE_DOWN) + .setPos(155, 23) + .setSize(10, 16)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractGenerator.java new file mode 100644 index 0000000000..08db4e19be --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractGenerator.java @@ -0,0 +1,832 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import static gtPlusPlus.core.lib.GTPPCore.sTesseractGeneratorOwnershipMap; +import static gtPlusPlus.core.lib.GTPPCore.sTesseractTerminalOwnershipMap; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IDigitalChest; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicTank; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; + +public class MTETesseractGenerator extends MTEBasicTank { + + public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + public static int TESSERACT_ENERGY_COST = 128; + public byte isWorking = 0; + public int oFrequency = 0; + public int mNeededEnergy = 0; + public int mFrequency = 0; + public UUID mOwner; + + public MTETesseractGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public MTETesseractGenerator(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTETesseractGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final ForgeDirection side) { + return true; + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return this.getBaseMetaTileEntity() + .getEUCapacity() / 2; + } + + @Override + public long maxEUInput() { + return 512; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxEUStore() { + return 512 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return (TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency) + == this) && (this.isWorking >= 20) ? 999 : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + if (mOwner != null) aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + try { + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } catch (IllegalArgumentException i) { + + } + } + + @Override + public void onConfigLoad() { + int J = 4; + TESSERACT_ENERGY_COST = 128 * J; + TESSERACT_ENERGY_COST_DIMENSIONAL = 512 * J; + } + + @Override + public void onServerStart() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + public void onServerStop() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, + final ForgeDirection side, final float aX, final float aY, final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity() + .getOwnerName() != null + && !this.getBaseMetaTileEntity() + .getOwnerName() + .equals("")) { + if (this.getBaseMetaTileEntity() + .getOwnerName() + .toLowerCase() + .equals( + aPlayer.getDisplayName() + .toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + } + } + } + + if (side == this.getBaseMetaTileEntity() + .getFrontFacing()) { + if (aPlayer.getUniqueID() + .compareTo(this.mOwner) == 0) { + final float[] tCoords = GTUtility.getClickedFacingCoords(side, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + Logger.WARNING("Freq. -1 | " + this.mFrequency); + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 1; + + break; + case 1: + Logger.WARNING("Freq. +1 | " + this.mFrequency); + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + break; + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { + GTUtility.sendChatToPlayer( + aPlayer, + "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } else { + GTUtility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } else if (aPlayer.getUniqueID() + .compareTo(this.mOwner) != 0) { + GTUtility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + return true; + } + + @Override + public void onScrewdriverRightClick(final ForgeDirection side, final EntityPlayer aPlayer, final float aX, + final float aY, final float aZ) { + if (aPlayer.getUniqueID() + .compareTo(this.mOwner) == 0) { + if (side == this.getBaseMetaTileEntity() + .getFrontFacing()) { + final float[] tCoords = GTUtility.getClickedFacingCoords(side, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0 -> { + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 64; + } + case 1 -> { + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 64; + } + case 2 -> { + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 512; + } + case 3 -> { + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 512; + } + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this) { + GTUtility.sendChatToPlayer( + aPlayer, + "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } else { + GTUtility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } + } else { + GTUtility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public String[] getInfoData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) + && ((tTileEntity instanceof IGregTechDeviceInformation)) + && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) { + return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, + (getGeneratorEntity() == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public boolean isSendingInformation() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation))) { + return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); + } + return false; + } + + @Override + public boolean isDigitalChest() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).isDigitalChest(); + } + return false; + } + + @Override + public ItemStack[] getStoredItemData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getStoredItemData(); + } + return new ItemStack[] {}; + } + + @Override + public void setItemCount(final int aCount) { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + ((IDigitalChest) tTileEntity).setItemCount(aCount); + } + } + + @Override + public int getMaxItemCount() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getMaxItemCount(); + } + return 0; + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int ordinalSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return new int[0]; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(ordinalSide); + } + final int[] rArray = new int[this.getSizeInventory()]; + for (int i = 0; i < this.getSizeInventory(); i++) { + rArray[i] = i; + } + return rArray; + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, ordinalSide); + } + return true; + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, ordinalSide); + } + return true; + } + + @Override + public int getSizeInventory() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide( + this.getBaseMetaTileEntity() + .getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + public boolean addEnergyConsumption(final MTETesseractTerminal aTerminal) { + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) { + return false; + } + int J = (aTerminal.getBaseMetaTileEntity() + .getWorld() + == this.getBaseMetaTileEntity() + .getWorld() ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); + + J *= 4; + + this.mNeededEnergy += J; + + return true; + } + + public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { + return (this.getBaseMetaTileEntity() != null) && (!this.getBaseMetaTileEntity() + .isInvalidTileEntity()) + && (this.getBaseMetaTileEntity() + .isAllowedToWork()) + && ((aOwnerName == null) || (this.getBaseMetaTileEntity() + .getOwnerName() + .equals(aOwnerName))) + && ((aWorkIrrelevant) || (this.isWorking >= 20)); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // TODO Auto-generated method stub + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // Utils.LOG_WARNING("Ticking Generator. 0"); + if (this.getBaseMetaTileEntity() + .isServerSide()) { + // Utils.LOG_WARNING("Ticking Generator."); + // Set owner + if (PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()) + != null) { + if (this.mOwner == null) { + Logger.WARNING("Setting Generators Owner. 1"); + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + } + } + + if (this.mFrequency != this.oFrequency) { + + Logger.WARNING("mFreq != oFreq"); + + if (getGeneratorEntity() == this) { + getGeneratorEntity(this.oFrequency); + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + Logger.WARNING("this Gen == oFreq on map - do block update"); + } + Logger.WARNING("mFreq will be set to oFreq"); + this.oFrequency = this.mFrequency; + } + if ((this.getBaseMetaTileEntity() + .isAllowedToWork()) + && (this.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(this.mNeededEnergy, false))) { + // Utils.LOG_WARNING("Can Work & Has Energy"); + if ((getGeneratorEntity(Integer.valueOf(this.mFrequency)) == null) + || (!getGeneratorEntity(Integer.valueOf(this.mFrequency)).isValidTesseractGenerator(null, true))) { + // Utils.LOG_WARNING("storing TE I think to mFreq map?"); + TesseractHelper.setGeneratorOwnershipByPlayer( + PlayerUtils.getPlayerOnServerFromUUID(mOwner), + this.mFrequency, + this); + } + } else { + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + Logger.WARNING("this gen == mFreq on map - do block update"); + TesseractHelper.removeGenerator(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + } + this.isWorking = 0; + } + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + // Utils.LOG_WARNING("mFreq == this - do work related things"); + if (this.isWorking < 20) { + this.isWorking = ((byte) (this.isWorking + 1)); + } + if (this.isWorking == 20) { + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + this.isWorking = ((byte) (this.isWorking + 1)); + } + } else { + this.isWorking = 0; + } + this.mNeededEnergy = 0; + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "Generates a Tesseract for the attached Inventory", + "Connect with pipes to insert items", + "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", + "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", + GTPPCore.GT_Tooltip.get()); + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return side == facing + ? new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(Textures.BlockIcons.VOID) }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + private MTETesseractGenerator getGeneratorEntity() { + MTETesseractGenerator thisGenerator = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + private MTETesseractGenerator getGeneratorEntity(int frequency) { + MTETesseractGenerator thisGenerator = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), frequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity() + .getOwnerName() != null + && !this.getBaseMetaTileEntity() + .getOwnerName() + .equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + Logger.WARNING("Setting Generators Owner. 2"); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + GTPPCore.sTesseractGeneratorOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + super.onRemoval(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractTerminal.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractTerminal.java new file mode 100644 index 0000000000..c34a2ca41b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/MTETesseractTerminal.java @@ -0,0 +1,642 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +import org.apache.commons.lang3.ArrayUtils; + +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.MTEBasicTank; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; + +public class MTETesseractTerminal extends MTEBasicTank { + + public int mFrequency = 0; + public UUID mOwner; + public boolean mDidWork = false; + public static boolean sInterDimensionalTesseractAllowed = true; + private static int TESSERACT_ENERGY_COST = 128; + private static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + + public MTETesseractTerminal(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public MTETesseractTerminal(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTETesseractTerminal(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return (this.getBaseMetaTileEntity() + .getEUCapacity() / 100); + } + + @Override + public long maxEUInput() { + return TESSERACT_ENERGY_COST_DIMENSIONAL; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUStore() { + return TESSERACT_ENERGY_COST_DIMENSIONAL * 8 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } + + @Override + public void onConfigLoad() { + sInterDimensionalTesseractAllowed = true; + TESSERACT_ENERGY_COST = 512; + TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, + final ForgeDirection side, final float aX, final float aY, final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity() + .getOwnerName() != null + && !this.getBaseMetaTileEntity() + .getOwnerName() + .equals("")) { + if (this.getBaseMetaTileEntity() + .getOwnerName() + .toLowerCase() + .equals( + aPlayer.getDisplayName() + .toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + } + } + } + + if (aPlayer.getUniqueID() + .compareTo(this.mOwner) == 0) { + if (side == this.getBaseMetaTileEntity() + .getFrontFacing()) { + final float[] tCoords = GTUtility.getClickedFacingCoords(side, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + // Utils.LOG_WARNING("Freq. -1 | " + this.mFrequency); + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 1; + break; + case 1: + // Utils.LOG_WARNING("Freq. +1 | " + this.mFrequency); + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + break; + } + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + if (this.getTesseract(this.mFrequency, false) != null) { + PlayerUtils.messagePlayer( + aPlayer, + new StringBuilder().append(EnumChatFormatting.GREEN) + .append(" (Connected)") + .toString()); + } + } + } else if (aPlayer.getUniqueID() + .compareTo(this.mOwner) != 0) { + GTUtility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + return true; + } + + @Override + public void onScrewdriverRightClick(final ForgeDirection side, final EntityPlayer aPlayer, final float aX, + final float aY, final float aZ) { + if (aPlayer.getUniqueID() + .compareTo(this.mOwner) == 0) { + if (side == this.getBaseMetaTileEntity() + .getFrontFacing()) { + final float[] tCoords = GTUtility.getClickedFacingCoords(side, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0 -> { + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 64; + } + case 1 -> { + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 64; + } + case 2 -> { + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency -= 512; + } + case 3 -> { + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + this.mFrequency += 512; + } + } + GTUtility.sendChatToPlayer( + aPlayer, + "Frequency: " + this.mFrequency + + (this.getTesseract(this.mFrequency, false) == null ? "" + : new StringBuilder().append(EnumChatFormatting.GREEN) + .append(" (Connected)") + .toString())); + } + } else if (aPlayer.getUniqueID() + .compareTo(this.mOwner) != 0) { + GTUtility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + } + + public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + public MTETesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { + final MTETesseractGenerator rTesseract = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), aFrequency); + if (rTesseract == null) { + return null; + } + if (!TesseractHelper.isGeneratorOwnedByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), rTesseract)) { + return null; + } + if (rTesseract.mFrequency != aFrequency) { + TesseractHelper.setTerminalOwnershipByPlayer( + PlayerUtils.getPlayerOnServerFromUUID(mOwner), + Integer.valueOf(aFrequency), + null); + return null; + } + if (!rTesseract.isValidTesseractGenerator( + this.getBaseMetaTileEntity() + .getOwnerName(), + aWorkIrrelevant)) { + return null; + } + if ((!sInterDimensionalTesseractAllowed) && (rTesseract.getBaseMetaTileEntity() + .getWorld() + != this.getBaseMetaTileEntity() + .getWorld())) { + return null; + } + return rTesseract; + } + + @Override + public String[] getInfoData() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity() + .isAllowedToWork()) && (tTileEntity.isSendingInformation())) { + return tTileEntity.getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, + this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isDigitalChest() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.isDigitalChest(); + } + + @Override + public ItemStack[] getStoredItemData() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.getStoredItemData(); + } + + @Override + public void setItemCount(final int aCount) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return; + } + tTileEntity.setItemCount(aCount); + } + + @Override + public int getMaxItemCount() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.getMaxItemCount(); + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int ordinalSide) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return new int[0]; + } + return tTileEntity.getAccessibleSlotsFromSide(ordinalSide); + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canInsertItem(aIndex, aStack, ordinalSide); + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int ordinalSide) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canExtractItem(aIndex, aStack, ordinalSide); + } + + @Override + public int getSizeInventory() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity() + .isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((this.getBaseMetaTileEntity() + .isServerSide()) + && (this.getBaseMetaTileEntity() + .isAllowedToWork())) { + // Set owner + if (PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()) + != null) { + if (this.mOwner == null) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + } + } + final MTETesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); + if (tTileEntity != null) { + tTileEntity.addEnergyConsumption(this); + if ((!this.mDidWork) && (this.getTesseract(this.mFrequency, false) != null)) { + this.mDidWork = true; + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + this.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(128, false); + } + } else if (this.mDidWork == true) { + this.mDidWork = false; + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + } + } + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "Accesses Tesseract Generators remotely", + "Connect with pipes to extract items or fluids", + "Outputs from the back face", + "Consumes " + TESSERACT_ENERGY_COST + "EU/t for same dimension transfers", + "Consumes " + TESSERACT_ENERGY_COST_DIMENSIONAL + "EU/t for cross dimensional transfers", + GTPPCore.GT_Tooltip.get()); + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return side == facing + ? new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(Textures.BlockIcons.VOID) }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity() + .getOwnerName() != null + && !this.getBaseMetaTileEntity() + .getOwnerName() + .equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName( + this.getBaseMetaTileEntity() + .getOwnerName()); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + GTPPCore.sTesseractTerminalOwnershipMap.get(mOwner) + .remove(this.mFrequency); + } catch (Throwable t) {} + super.onRemoval(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java deleted file mode 100644 index 6200a37872..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java +++ /dev/null @@ -1,332 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidTankInfo; - -import org.apache.commons.lang3.ArrayUtils; -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.drawable.UITexture; - -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.gui.modularui.GUITextureSet; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; - -public class GT_MetaTileEntity_Boiler_Base extends GT_MetaTileEntity_Boiler { - - private final int steamPerSecond; - private final int tier; - - public GT_MetaTileEntity_Boiler_Base(int aID, String aNameRegional, int tier) { - super( - aID, - "electricboiler." + tier + ".tier.single", - aNameRegional, - "Produces " + (CORE.ConfigSwitches.boilerSteamPerSecond * tier) + "L of Steam per second"); - this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * tier); - this.tier = tier; - } - - public GT_MetaTileEntity_Boiler_Base(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * aTier); - this.tier = aTier; - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "Produces " + getPollution() + " pollution/sec", - "Consumes fuel only when temperature is less than 100C", - "Fuel with burn time greater than 500 is more efficient.", - "Doesn't explode if there's no water", - CORE.GT_Tooltip.get()); - } - - public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - protected GT_RenderedTexture getCasingTexture() { - if (this.tier == 1) { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); - } else if (this.tier == 2) { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); - } else { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); - } - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture() }; - } - - public ITexture[] getBack(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getBottom(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getTop(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture() }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getSides(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isFacingValid(final ForgeDirection side) { - return side.offsetY == 0; - } - - // Please find out what I do. - // I do stuff within the GUI. - // this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) - // this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - @Override - public int maxProgresstime() { - return 1000 + (250 * tier); - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public int getCapacity() { - return (16000 + (16000 * tier)); - } - - // This type of machine can have different water and steam capacities. - @Override - public int getSteamCapacity() { - return 2 * getCapacity(); - } - - @Override - protected int getProductionPerSecond() { - return steamPerSecond; - } - - @Override - protected int getMaxTemperature() { - return maxProgresstime(); - } - - @Override - protected int getEnergyConsumption() { - return 2; - } - - @Override - protected int getCooldownInterval() { - return 40; - } - - @Override - protected int getHeatUpRate() { - return 10; - } - - @Override - protected void updateFuel(IGregTechTileEntity tile, long ticks) { - ItemStack fuelStack = this.mInventory[2]; - if (fuelStack == null) return; - - int burnTime = getBurnTime(fuelStack); - if (burnTime > 0 && this.mTemperature <= 101) { - consumeFuel(tile, fuelStack, burnTime); - } - } - - @Override - protected boolean isItemValidFuel(@NotNull ItemStack stack) { - return getBurnTime(stack) > 0; - } - - @Override - // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to - // support returning those different capacities. - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - return new FluidTankInfo[] { new FluidTankInfo(this.mFluid, getCapacity()), - new FluidTankInfo(this.mSteam, getSteamCapacity()) }; - } - - @Override - protected boolean isAutomatable() { - return true; - } - - @Override - protected int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondBoiler - * CORE.ConfigSwitches.pollutionReleasedByTierBoiler[this.tier]); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Base(this.mName, tier, this.mDescriptionArray, this.mTextures); - } - - @Override - protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { - // Smart boilers don't explode! - } - - /** - * Returns burn time if the stack is a valid fuel, otherwise return 0. - */ - private static int getBurnTime(ItemStack stack) { - int burnTime = GameRegistry.getFuelValue(stack); - if (burnTime <= 0) { - burnTime = TileEntityFurnace.getItemBurnTime(stack); - } - - return burnTime; - } - - public void consumeFuel(IGregTechTileEntity tile, ItemStack fuel, int burnTime) { - this.mProcessingEnergy += burnTime / 10; - this.mTemperature += burnTime / 500; // will add bonus temperature points if the burn time is pretty high - - tile.decrStackSize(2, 1); - if (tile.getRandomNumber(3) == 0) { - if (fuel.getDisplayName() - .toLowerCase() - .contains("charcoal") - || fuel.getDisplayName() - .toLowerCase() - .contains("coke")) { - tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } else { - tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCover) { - if (side != this.getBaseMetaTileEntity() - .getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(side, aCover); - } - - @Override - public GUITextureSet getGUITextureSet() { - return GUITextureSet.DEFAULT; - } - - @Override - protected IDrawable[] getFuelSlotBackground() { - return new IDrawable[] { getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_COAL }; - } - - @Override - protected IDrawable[] getAshSlotBackground() { - return new IDrawable[] { getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_DUST }; - } - - @Override - public int getTitleColor() { - return COLOR_TITLE.get(); - } - - @Override - protected IDrawable getOverlaySlotIn() { - return GT_UITextures.OVERLAY_SLOT_IN; - } - - @Override - protected IDrawable getOverlaySlotOut() { - return GT_UITextures.OVERLAY_SLOT_OUT; - } - - @Override - protected IDrawable getOverlaySlotCanister() { - return GTPP_UITextures.OVERLAY_SLOT_CANISTER_DARK; - } - - @Override - protected UITexture getProgressbarEmpty() { - return GTPP_UITextures.PROGRESSBAR_BOILER_EMPTY; - } - - @Override - protected UITexture getProgressbarFuel() { - return GTPP_UITextures.PROGRESSBAR_FUEL; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java deleted file mode 100644 index e24698812f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java +++ /dev/null @@ -1,51 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; - -public class GT_MetaTileEntity_Boiler_HV extends GT_MetaTileEntity_Boiler_Base { - - public GT_MetaTileEntity_Boiler_HV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); - } - - public GT_MetaTileEntity_Boiler_HV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_HV(this.mName, 3, this.mDescriptionArray, this.mTextures); - } - - @Override - protected GT_RenderedTexture getCasingTexture() { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_TOP) }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java deleted file mode 100644 index adaec8a51e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java +++ /dev/null @@ -1,51 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; - -public class GT_MetaTileEntity_Boiler_LV extends GT_MetaTileEntity_Boiler_Base { - - public GT_MetaTileEntity_Boiler_LV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); - } - - public GT_MetaTileEntity_Boiler_LV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_LV(this.mName, 1, this.mDescriptionArray, this.mTextures); - } - - @Override - protected GT_RenderedTexture getCasingTexture() { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_TOP) }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java deleted file mode 100644 index dce70d4ccf..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java +++ /dev/null @@ -1,51 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; - -public class GT_MetaTileEntity_Boiler_MV extends GT_MetaTileEntity_Boiler_Base { - - public GT_MetaTileEntity_Boiler_MV(int aID, String aNameRegional, int aBoilerTier) { - super(aID, aNameRegional, aBoilerTier); - } - - public GT_MetaTileEntity_Boiler_MV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_MV(this.mName, 2, this.mDescriptionArray, this.mTextures); - } - - @Override - protected GT_RenderedTexture getCasingTexture() { - return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_TOP) }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return getTop(aColor); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java deleted file mode 100644 index bbb5ae9da4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java +++ /dev/null @@ -1,162 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.lib.CORE; - -public class GT_MetaTileEntity_SemiFluidGenerator extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires semi-fluid Fuel", new ITexture[0]); - } - - public GT_MetaTileEntity_SemiFluidGenerator(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator - * CORE.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator[this.mTier]); - } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SemiFluidGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - // Logger.WARNING("Fuel Count: "+Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size()); - return GTPPRecipeMaps.semiFluidFuels; - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "Produces " + (this.getPollution()) + " pollution/sec", - "Fuel Efficiency: " + this.getEfficiency() + "%", - CORE.GT_Tooltip.get()); - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return (side == getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCover) { - if (side != this.getBaseMetaTileEntity() - .getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(side, aCover); - } - - @Override - public int getFuelValue(ItemStack aStack) { - if ((GT_Utility.isStackInvalid(aStack)) || (getRecipeMap() == null)) { - Logger.WARNING("Bad Fuel?"); - return 0; - } - int rValue = Math.max(GT_ModHandler.getFuelValue(aStack) * 6 / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - Logger.WARNING("Good Fuel: " + rValue); - return rValue; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java deleted file mode 100644 index af235556c8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ /dev/null @@ -1,171 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import cpw.mods.fml.common.registry.GameRegistry; -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.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.util.GT_ModHandler; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntityGeothermalGenerator extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GregtechMetaTileEntityGeothermalGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); - this.setEfficiency(); - } - - public GregtechMetaTileEntityGeothermalGenerator(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.setEfficiency(); - } - - @Override - public String[] getDescription() { - String aPollution = "Causes " + this.getPollution() + " Pollution per second"; - return ArrayUtils.addAll( - this.mDescriptionArray, - "Generates power at " + this.getEfficiency() + "% Efficiency per tick", - aPollution, - CORE.GT_Tooltip.get()); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public int getCapacity() { - // return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); - return 5000 * this.mTier; - } - - public void setEfficiency() { - this.mEfficiency = (100 - (this.mTier * 7)); - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public int getFuelValue(final ItemStack aStack) { - int rValue = Math.max((GT_ModHandler.getFuelValue(aStack) * 6) / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - return rValue; - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeothermalGenerator( - this.mName, - this.mTier, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical) }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER) }; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT) }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active) }; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE) }; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE) }; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.hotFuels; - } - - @Override - public int getPollution() { - return (int) (CORE.ConfigSwitches.basePollutionPerSecondGeothermalGenerator - * CORE.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator[mTier]); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java deleted file mode 100644 index 5b1a45e16f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ /dev/null @@ -1,145 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_ModHandler; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntityRocketFuelGenerator extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); - } - - public GregtechMetaTileEntityRocketFuelGenerator(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.mEfficiency = getEfficiency(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityRocketFuelGenerator( - this.mName, - this.mTier, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.rocketFuels; - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public int getEfficiency() { - return 80 - (10 * (this.mTier - 4)); - } - - @Override - public int getFuelValue(final ItemStack aStack) { - int rValue = Math.max((GT_ModHandler.getFuelValue(aStack) * 6) / 5, super.getFuelValue(aStack)); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); - } - return rValue; - } - - private GT_RenderedTexture getCasingTexture() { - if (this.mTier <= 4) { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } else if (this.mTier == 5) { - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } else { - - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); - } - // return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) }; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) }; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) }; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java deleted file mode 100644 index 32cf3a92cc..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java +++ /dev/null @@ -1,379 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; - -public class GregtechMetaTileEntity_RTG extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - private long mTicksToBurnFor; - private int mVoltage = 0; - private GT_Recipe mCurrentRecipe; - private int mDaysRemaining = 0; - private int mDayTick = 0; - private byte mNewTier = 0; - - public int removeDayOfTime() { - if (this.mDaysRemaining > 0) { - return this.mDaysRemaining--; - } - return this.mDaysRemaining; - } - - // Generates fuel value based on MC days - public static int convertDaysToTicks(float days) { - int value = 0; - value = MathUtils.roundToClosestInt(20 * 86400 * days); - return value; - } - - public static long getTotalEUGenerated(int ticks, int voltage) { - return ticks * voltage; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setLong("mTicksToBurnFor", this.mTicksToBurnFor); - aNBT.setInteger("mVoltage", this.mVoltage); - aNBT.setInteger("mDaysRemaining", this.mDaysRemaining); - aNBT.setInteger("mDayTick", this.mDayTick); - aNBT.setByte("mNewTier", this.mNewTier); - - if (this.mCurrentRecipe != null) { - final NBTTagList list = new NBTTagList(); - final ItemStack stack = this.mCurrentRecipe.mInputs[0]; - if (stack != null) { - final NBTTagCompound data = new NBTTagCompound(); - stack.writeToNBT(data); - data.setInteger("mSlot", 0); - list.appendTag(data); - } - aNBT.setTag("mRecipeItem", list); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); - this.mVoltage = aNBT.getInteger("mVoltage"); - this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); - this.mDayTick = aNBT.getInteger("mDayTick"); - this.mNewTier = aNBT.getByte("mNewTier"); - - try { - ReflectionUtils.setByte(this, "mTier", this.mNewTier); - } catch (Exception e) { - if (this.getBaseMetaTileEntity() != null) { - IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); - if (thisTile.isAllowedToWork() || thisTile.isActive()) { - thisTile.setActive(false); - } - } - } - - final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); - final NBTTagCompound data = list.getCompoundTagAt(0); - ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); - if (lastUsedFuel != null) { - this.mCurrentRecipe = getRecipeMap().findRecipe( - getBaseMetaTileEntity(), - false, - 9223372036854775807L, - null, - new ItemStack[] { lastUsedFuel }); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mDayTick < 24000) { - this.mDayTick++; - } else if (this.mDayTick >= 24000) { - this.mDayTick = 0; - this.mDaysRemaining = this.removeDayOfTime(); - } - } - - if ((aBaseMetaTileEntity.isServerSide()) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 10L == 0L)) { - long tProducedEU = 0L; - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { - this.mInventory[getStackDisplaySlot()] = null; - } else { - if (this.mInventory[getStackDisplaySlot()] == null) - this.mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - this.mInventory[getStackDisplaySlot()].setStackDisplayName( - "Generating: " - + GT_Utility.formatNumbers( - aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) - + " EU"); - } - } else { - int tFuelValue = getFuelValue(this.mFluid); - int tConsumed = consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { - long tFluidAmountToUse = Math.min( - this.mFluid.amount / tConsumed, - (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0L) - && (aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true))) { - tProducedEU = tFluidAmountToUse * tFuelValue; - FluidStack tmp260_257 = this.mFluid; - tmp260_257.amount = (int) (tmp260_257.amount - (tFluidAmountToUse * tConsumed)); - } - } - } - if ((this.mInventory[getInputSlot()] != null) - && (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() * 20L + getMinimumStoredEU()) - && (GT_Utility.getFluidForFilledItem(this.mInventory[getInputSlot()], true) == null)) { - int tFuelValue = getFuelValue(this.mInventory[getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = getEmptyContainer(this.mInventory[getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - tProducedEU = tFuelValue; - } - } - } - if ((tProducedEU > 0L) && (getPollution() > 0)) { - PollutionUtils - .addPollution(aBaseMetaTileEntity, (int) (tProducedEU * getPollution() / 500 * this.mTier + 1L)); - } - } - - if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive( - (aBaseMetaTileEntity.isAllowedToWork()) - && (aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU())); - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "Fuel is measured in minecraft days (Check with Scanner)", - "RTG changes output voltage depending on fuel", - "Generates power at " + GT_Utility.formatNumbers(this.getEfficiency()) + "% Efficiency per tick", - "Output Voltage: " + GT_Utility.formatNumbers(this.getOutputTier()) + " EU/t", - CORE.GT_Tooltip.get()); - } - - public GregtechMetaTileEntity_RTG(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires RTG Pellets", new ITexture[0]); - } - - private byte getTier() { - int voltage = this.mVoltage; - if (voltage >= 512) { - return 4; - } else if (voltage >= 128) { - return 3; - } else if (voltage >= 32) { - return 2; - } else if (voltage >= 8) { - return 1; - } - return 0; - } - - public GregtechMetaTileEntity_RTG(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return ((side.offsetY == 0) && (side != getBaseMetaTileEntity().getFrontFacing()) - && (side != getBaseMetaTileEntity().getBackFacing())); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_RTG(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.rtgFuels; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public int getEfficiency() { - return this.mEfficiency = 100; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], - new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] }; - } - - @Override - public int getPollution() { - return 0; - } - - @Override - public int getFuelValue(ItemStack aStack) { - if ((GT_Utility.isStackInvalid(aStack)) || (getRecipeMap() == null)) return 0; - GT_Recipe tFuel = getRecipeMap() - .findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] { aStack }); - if (tFuel != null) { - this.mCurrentRecipe = tFuel; - int voltage = tFuel.mEUt; - this.mVoltage = voltage; - // this.mDaysRemaining = tFuel.mSpecialValue*365; - - // Do some voodoo. - byte mTier2; - // mTier2 = ReflectionUtils.getField(this.getClass(), "mTier"); - try { - if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_AM241.get(1))) { - mTier2 = 1; - } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PO210.get(1))) { - mTier2 = 3; - } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1))) { - mTier2 = 2; - } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_SR90.get(1))) { - mTier2 = 1; - } else { - mTier2 = 0; - } - ReflectionUtils.setByte(this, "mTier", mTier2); - this.mNewTier = mTier2; - } catch (Exception e) { - Logger.WARNING("Failed setting mTier."); - e.printStackTrace(); - } - - this.mTicksToBurnFor = getTotalEUGenerated(convertDaysToTicks(tFuel.mSpecialValue), voltage); - if (mTicksToBurnFor >= Integer.MAX_VALUE) { - mTicksToBurnFor = Integer.MAX_VALUE; - Logger.WARNING("Fuel went over Int limit, setting to MAX_VALUE."); - } - this.mDaysRemaining = MathUtils.roundToClosestInt(mTicksToBurnFor / 20 / 60 / 3); - Logger.WARNING("step | " + (int) (mTicksToBurnFor * getEfficiency() / 100L)); - return (int) (mTicksToBurnFor * getEfficiency() / 100L); - } - Logger.WARNING("Not sure"); - return 0; - } - - @Override - public long maxEUOutput() { - return ((getBaseMetaTileEntity().isAllowedToWork()) ? this.mVoltage : 0L); - } - - @Override - public long getOutputTier() { - if (this.mCurrentRecipe != null) { - return this.mVoltage = this.mCurrentRecipe.mEUt; - } - return 0; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[] { "RTG - Running at tier " + this.mTier, "Active: " + this.getBaseMetaTileEntity() - .isActive(), "Current Output: " + GT_Utility.formatNumbers(mVoltage) + " EU/t", - "Days of Fuel remaining: " + GT_Utility.formatNumbers(mTicksToBurnFor / 20 / 60 / 20), - "Hours of Fuel remaining: " + GT_Utility.formatNumbers(mTicksToBurnFor / 20 / 60 / 60), - "Ticks of " + this.mVoltage + "v remaining: " + mTicksToBurnFor, - this.mCurrentRecipe.mInputs[0].getDisplayName() + " x1" }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerBase.java new file mode 100644 index 0000000000..b3a367bcaf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerBase.java @@ -0,0 +1,332 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTankInfo; + +import org.apache.commons.lang3.ArrayUtils; +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.common.tileentities.boilers.MTEBoiler; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; + +public class MTEBoilerBase extends MTEBoiler { + + private final int steamPerSecond; + private final int tier; + + public MTEBoilerBase(int aID, String aNameRegional, int tier) { + super( + aID, + "electricboiler." + tier + ".tier.single", + aNameRegional, + "Produces " + (GTPPCore.ConfigSwitches.boilerSteamPerSecond * tier) + "L of Steam per second"); + this.steamPerSecond = (GTPPCore.ConfigSwitches.boilerSteamPerSecond * tier); + this.tier = tier; + } + + public MTEBoilerBase(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.steamPerSecond = (GTPPCore.ConfigSwitches.boilerSteamPerSecond * aTier); + this.tier = aTier; + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "Produces " + getPollution() + " pollution/sec", + "Consumes fuel only when temperature is less than 100C", + "Fuel with burn time greater than 500 is more efficient.", + "Doesn't explode if there's no water", + GTPPCore.GT_Tooltip.get()); + } + + public ITexture getOverlayIcon() { + return new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + protected GTRenderedTexture getCasingTexture() { + if (this.tier == 1) { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } else if (this.tier == 2) { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } else { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture() }; + } + + public ITexture[] getBack(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottom(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getTop(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], this.getCasingTexture() }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isFacingValid(final ForgeDirection side) { + return side.offsetY == 0; + } + + // Please find out what I do. + // I do stuff within the GUI. + // this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) + // this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + @Override + public int maxProgresstime() { + return 1000 + (250 * tier); + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public int getCapacity() { + return (16000 + (16000 * tier)); + } + + // This type of machine can have different water and steam capacities. + @Override + public int getSteamCapacity() { + return 2 * getCapacity(); + } + + @Override + protected int getProductionPerSecond() { + return steamPerSecond; + } + + @Override + protected int getMaxTemperature() { + return maxProgresstime(); + } + + @Override + protected int getEnergyConsumption() { + return 2; + } + + @Override + protected int getCooldownInterval() { + return 40; + } + + @Override + protected int getHeatUpRate() { + return 10; + } + + @Override + protected void updateFuel(IGregTechTileEntity tile, long ticks) { + ItemStack fuelStack = this.mInventory[2]; + if (fuelStack == null) return; + + int burnTime = getBurnTime(fuelStack); + if (burnTime > 0 && this.mTemperature <= 101) { + consumeFuel(tile, fuelStack, burnTime); + } + } + + @Override + protected boolean isItemValidFuel(@NotNull ItemStack stack) { + return getBurnTime(stack) > 0; + } + + @Override + // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to + // support returning those different capacities. + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + return new FluidTankInfo[] { new FluidTankInfo(this.mFluid, getCapacity()), + new FluidTankInfo(this.mSteam, getSteamCapacity()) }; + } + + @Override + protected boolean isAutomatable() { + return true; + } + + @Override + protected int getPollution() { + return (int) (GTPPCore.ConfigSwitches.basePollutionPerSecondBoiler + * GTPPCore.ConfigSwitches.pollutionReleasedByTierBoiler[this.tier]); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBoilerBase(this.mName, tier, this.mDescriptionArray, this.mTextures); + } + + @Override + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { + // Smart boilers don't explode! + } + + /** + * Returns burn time if the stack is a valid fuel, otherwise return 0. + */ + private static int getBurnTime(ItemStack stack) { + int burnTime = GameRegistry.getFuelValue(stack); + if (burnTime <= 0) { + burnTime = TileEntityFurnace.getItemBurnTime(stack); + } + + return burnTime; + } + + public void consumeFuel(IGregTechTileEntity tile, ItemStack fuel, int burnTime) { + this.mProcessingEnergy += burnTime / 10; + this.mTemperature += burnTime / 500; // will add bonus temperature points if the burn time is pretty high + + tile.decrStackSize(2, 1); + if (tile.getRandomNumber(3) == 0) { + if (fuel.getDisplayName() + .toLowerCase() + .contains("charcoal") + || fuel.getDisplayName() + .toLowerCase() + .contains("coke")) { + tile.addStackToSlot(3, GTOreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } else { + tile.addStackToSlot(3, GTOreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aCover) { + if (side != this.getBaseMetaTileEntity() + .getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(side, aCover); + } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.DEFAULT; + } + + @Override + protected IDrawable[] getFuelSlotBackground() { + return new IDrawable[] { getGUITextureSet().getItemSlot(), GTPPUITextures.OVERLAY_SLOT_COAL }; + } + + @Override + protected IDrawable[] getAshSlotBackground() { + return new IDrawable[] { getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_DUST }; + } + + @Override + public int getTitleColor() { + return COLOR_TITLE.get(); + } + + @Override + protected IDrawable getOverlaySlotIn() { + return GTUITextures.OVERLAY_SLOT_IN; + } + + @Override + protected IDrawable getOverlaySlotOut() { + return GTUITextures.OVERLAY_SLOT_OUT; + } + + @Override + protected IDrawable getOverlaySlotCanister() { + return GTPPUITextures.OVERLAY_SLOT_CANISTER_DARK; + } + + @Override + protected UITexture getProgressbarEmpty() { + return GTPPUITextures.PROGRESSBAR_BOILER_EMPTY; + } + + @Override + protected UITexture getProgressbarFuel() { + return GTPPUITextures.PROGRESSBAR_FUEL; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerHV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerHV.java new file mode 100644 index 0000000000..6bb0c658bd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerHV.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; + +public class MTEBoilerHV extends MTEBoilerBase { + + public MTEBoilerHV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public MTEBoilerHV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBoilerHV(this.mName, 3, this.mDescriptionArray, this.mTextures); + } + + @Override + protected GTRenderedTexture getCasingTexture() { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.MACHINE_HV_TOP) }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerLV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerLV.java new file mode 100644 index 0000000000..0d8c03e448 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerLV.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; + +public class MTEBoilerLV extends MTEBoilerBase { + + public MTEBoilerLV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public MTEBoilerLV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBoilerLV(this.mName, 1, this.mDescriptionArray, this.mTextures); + } + + @Override + protected GTRenderedTexture getCasingTexture() { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.MACHINE_LV_TOP) }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerMV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerMV.java new file mode 100644 index 0000000000..32bda689c2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEBoilerMV.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; + +public class MTEBoilerMV extends MTEBoilerBase { + + public MTEBoilerMV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public MTEBoilerMV(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBoilerMV(this.mName, 2, this.mDescriptionArray, this.mTextures); + } + + @Override + protected GTRenderedTexture getCasingTexture() { + return new GTRenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.MACHINE_MV_TOP) }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEGeothermalGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEGeothermalGenerator.java new file mode 100644 index 0000000000..4fac228f4f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTEGeothermalGenerator.java @@ -0,0 +1,166 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTModHandler; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEGeothermalGenerator extends MTEBasicGenerator { + + public int mEfficiency; + + public MTEGeothermalGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); + this.setEfficiency(); + } + + public MTEGeothermalGenerator(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.setEfficiency(); + } + + @Override + public String[] getDescription() { + String aPollution = "Causes " + this.getPollution() + " Pollution per second"; + return ArrayUtils.addAll( + this.mDescriptionArray, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + aPollution, + GTPPCore.GT_Tooltip.get()); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public int getCapacity() { + // return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000 * this.mTier; + } + + public void setEfficiency() { + this.mEfficiency = (100 - (this.mTier * 7)); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GTModHandler.getFuelValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEGeothermalGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical) }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER) }; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT) }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active) }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE) }; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE) }; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.hotFuels; + } + + @Override + public int getPollution() { + return (int) (GTPPCore.ConfigSwitches.basePollutionPerSecondGeothermalGenerator + * GTPPCore.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator[mTier]); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java new file mode 100644 index 0000000000..00a915b89c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java @@ -0,0 +1,379 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +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.MTEBasicGenerator; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class MTERTGenerator extends MTEBasicGenerator { + + public int mEfficiency; + private long mTicksToBurnFor; + private int mVoltage = 0; + private GTRecipe mCurrentRecipe; + private int mDaysRemaining = 0; + private int mDayTick = 0; + private byte mNewTier = 0; + + public int removeDayOfTime() { + if (this.mDaysRemaining > 0) { + return this.mDaysRemaining--; + } + return this.mDaysRemaining; + } + + // Generates fuel value based on MC days + public static int convertDaysToTicks(float days) { + int value = 0; + value = MathUtils.roundToClosestInt(20 * 86400 * days); + return value; + } + + public static long getTotalEUGenerated(int ticks, int voltage) { + return ticks * voltage; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("mTicksToBurnFor", this.mTicksToBurnFor); + aNBT.setInteger("mVoltage", this.mVoltage); + aNBT.setInteger("mDaysRemaining", this.mDaysRemaining); + aNBT.setInteger("mDayTick", this.mDayTick); + aNBT.setByte("mNewTier", this.mNewTier); + + if (this.mCurrentRecipe != null) { + final NBTTagList list = new NBTTagList(); + final ItemStack stack = this.mCurrentRecipe.mInputs[0]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("mSlot", 0); + list.appendTag(data); + } + aNBT.setTag("mRecipeItem", list); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); + this.mVoltage = aNBT.getInteger("mVoltage"); + this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); + this.mDayTick = aNBT.getInteger("mDayTick"); + this.mNewTier = aNBT.getByte("mNewTier"); + + try { + ReflectionUtils.setByte(this, "mTier", this.mNewTier); + } catch (Exception e) { + if (this.getBaseMetaTileEntity() != null) { + IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); + if (thisTile.isAllowedToWork() || thisTile.isActive()) { + thisTile.setActive(false); + } + } + } + + final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); + final NBTTagCompound data = list.getCompoundTagAt(0); + ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); + if (lastUsedFuel != null) { + this.mCurrentRecipe = getRecipeMap().findRecipe( + getBaseMetaTileEntity(), + false, + 9223372036854775807L, + null, + new ItemStack[] { lastUsedFuel }); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mDayTick < 24000) { + this.mDayTick++; + } else if (this.mDayTick >= 24000) { + this.mDayTick = 0; + this.mDaysRemaining = this.removeDayOfTime(); + } + } + + if ((aBaseMetaTileEntity.isServerSide()) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 10L == 0L)) { + long tProducedEU = 0L; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + this.mInventory[getStackDisplaySlot()] = null; + } else { + if (this.mInventory[getStackDisplaySlot()] == null) + this.mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + this.mInventory[getStackDisplaySlot()].setStackDisplayName( + "Generating: " + + GTUtility.formatNumbers( + aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + + " EU"); + } + } else { + int tFuelValue = getFuelValue(this.mFluid); + int tConsumed = consumedFluidPerOperation(this.mFluid); + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + long tFluidAmountToUse = Math.min( + this.mFluid.amount / tConsumed, + (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + if ((tFluidAmountToUse > 0L) + && (aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true))) { + tProducedEU = tFluidAmountToUse * tFuelValue; + FluidStack tmp260_257 = this.mFluid; + tmp260_257.amount = (int) (tmp260_257.amount - (tFluidAmountToUse * tConsumed)); + } + } + } + if ((this.mInventory[getInputSlot()] != null) + && (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() * 20L + getMinimumStoredEU()) + && (GTUtility.getFluidForFilledItem(this.mInventory[getInputSlot()], true) == null)) { + int tFuelValue = getFuelValue(this.mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(this.mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + tProducedEU = tFuelValue; + } + } + } + if ((tProducedEU > 0L) && (getPollution() > 0)) { + PollutionUtils + .addPollution(aBaseMetaTileEntity, (int) (tProducedEU * getPollution() / 500 * this.mTier + 1L)); + } + } + + if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive( + (aBaseMetaTileEntity.isAllowedToWork()) + && (aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU())); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "Fuel is measured in minecraft days (Check with Scanner)", + "RTG changes output voltage depending on fuel", + "Generates power at " + GTUtility.formatNumbers(this.getEfficiency()) + "% Efficiency per tick", + "Output Voltage: " + GTUtility.formatNumbers(this.getOutputTier()) + " EU/t", + GTPPCore.GT_Tooltip.get()); + } + + public MTERTGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires RTG Pellets", new ITexture[0]); + } + + private byte getTier() { + int voltage = this.mVoltage; + if (voltage >= 512) { + return 4; + } else if (voltage >= 128) { + return 3; + } else if (voltage >= 32) { + return 2; + } else if (voltage >= 8) { + return 1; + } + return 0; + } + + public MTERTGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return ((side.offsetY == 0) && (side != getBaseMetaTileEntity().getFrontFacing()) + && (side != getBaseMetaTileEntity().getBackFacing())); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERTGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.rtgFuels; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public int getEfficiency() { + return this.mEfficiency = 100; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GTRenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()] }; + } + + @Override + public int getPollution() { + return 0; + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GTUtility.isStackInvalid(aStack)) || (getRecipeMap() == null)) return 0; + GTRecipe tFuel = getRecipeMap() + .findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] { aStack }); + if (tFuel != null) { + this.mCurrentRecipe = tFuel; + int voltage = tFuel.mEUt; + this.mVoltage = voltage; + // this.mDaysRemaining = tFuel.mSpecialValue*365; + + // Do some voodoo. + byte mTier2; + // mTier2 = ReflectionUtils.getField(this.getClass(), "mTier"); + try { + if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_AM241.get(1))) { + mTier2 = 1; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PO210.get(1))) { + mTier2 = 3; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1))) { + mTier2 = 2; + } else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_SR90.get(1))) { + mTier2 = 1; + } else { + mTier2 = 0; + } + ReflectionUtils.setByte(this, "mTier", mTier2); + this.mNewTier = mTier2; + } catch (Exception e) { + Logger.WARNING("Failed setting mTier."); + e.printStackTrace(); + } + + this.mTicksToBurnFor = getTotalEUGenerated(convertDaysToTicks(tFuel.mSpecialValue), voltage); + if (mTicksToBurnFor >= Integer.MAX_VALUE) { + mTicksToBurnFor = Integer.MAX_VALUE; + Logger.WARNING("Fuel went over Int limit, setting to MAX_VALUE."); + } + this.mDaysRemaining = MathUtils.roundToClosestInt(mTicksToBurnFor / 20 / 60 / 3); + Logger.WARNING("step | " + (int) (mTicksToBurnFor * getEfficiency() / 100L)); + return (int) (mTicksToBurnFor * getEfficiency() / 100L); + } + Logger.WARNING("Not sure"); + return 0; + } + + @Override + public long maxEUOutput() { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? this.mVoltage : 0L); + } + + @Override + public long getOutputTier() { + if (this.mCurrentRecipe != null) { + return this.mVoltage = this.mCurrentRecipe.mEUt; + } + return 0; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { "RTG - Running at tier " + this.mTier, "Active: " + this.getBaseMetaTileEntity() + .isActive(), "Current Output: " + GTUtility.formatNumbers(mVoltage) + " EU/t", + "Days of Fuel remaining: " + GTUtility.formatNumbers(mTicksToBurnFor / 20 / 60 / 20), + "Hours of Fuel remaining: " + GTUtility.formatNumbers(mTicksToBurnFor / 20 / 60 / 60), + "Ticks of " + this.mVoltage + "v remaining: " + mTicksToBurnFor, + this.mCurrentRecipe.mInputs[0].getDisplayName() + " x1" }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERocketFuelGenerator.java new file mode 100644 index 0000000000..48c3a63007 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERocketFuelGenerator.java @@ -0,0 +1,140 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTModHandler; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.MTERocketFuelGeneratorBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTERocketFuelGenerator extends MTERocketFuelGeneratorBase { + + public int mEfficiency; + + public MTERocketFuelGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); + } + + public MTERocketFuelGenerator(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.mEfficiency = getEfficiency(); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTERocketFuelGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.rocketFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getEfficiency() { + return 80 - (10 * (this.mTier - 4)); + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GTModHandler.getFuelValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GTRenderedTexture getCasingTexture() { + if (this.mTier <= 4) { + return new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } else if (this.mTier == 5) { + + return new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } else { + + return new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + // return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) }; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) }; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) }; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], this.getCasingTexture(), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) }; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) }; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], this.getCasingTexture(), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTESemiFluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTESemiFluidGenerator.java new file mode 100644 index 0000000000..4c893eb92d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTESemiFluidGenerator.java @@ -0,0 +1,161 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +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.MTEBasicGenerator; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.lib.GTPPCore; + +public class MTESemiFluidGenerator extends MTEBasicGenerator { + + public int mEfficiency; + + public MTESemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires semi-fluid Fuel", new ITexture[0]); + } + + public MTESemiFluidGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getPollution() { + return (int) (GTPPCore.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator + * GTPPCore.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator[this.mTier]); + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESemiFluidGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + // Logger.WARNING("Fuel Count: "+Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size()); + return GTPPRecipeMaps.semiFluidFuels; + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "Produces " + (this.getPollution()) + " pollution/sec", + "Fuel Efficiency: " + this.getEfficiency() + "%", + GTPPCore.GT_Tooltip.get()); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return (side == getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aCover) { + if (side != this.getBaseMetaTileEntity() + .getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(side, aCover); + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GTUtility.isStackInvalid(aStack)) || (getRecipeMap() == null)) { + Logger.WARNING("Bad Fuel?"); + return 0; + } + int rValue = Math.max(GTModHandler.getFuelValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + Logger.WARNING("Good Fuel: " + rValue); + return rValue; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + new GTRenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java deleted file mode 100644 index b93a3cbfd0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CropHarvestor.java +++ /dev/null @@ -1,706 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import com.gtnewhorizon.gtnhlib.util.map.ItemStackMap; -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 com.gtnewhorizons.modularui.common.widget.ProgressBar; -import com.gtnewhorizons.modularui.common.widget.SlotGroup; - -import gregtech.api.enums.GT_Values; -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.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import ic2.api.crops.CropCard; -import ic2.api.crops.ICropTile; -import ic2.core.item.DamageHandler; - -public class GT_MetaTileEntity_CropHarvestor extends GT_MetaTileEntity_BasicTank { - - private static final int SLOT_WEEDEX_1 = 1; - private static final int SLOT_WEEDEX_2 = 2; - private static final int SLOT_FERT_1 = 3; - private static final int SLOT_FERT_4 = 6; - private static final int SLOT_OUTPUT_START = 7; - - public boolean mModeAlternative = false; - public boolean mHarvestEnabled = true; - - public GT_MetaTileEntity_CropHarvestor(final int aID, final int aTier, final String aDescription) { - super( - aID, - "basicmachine.cropharvester.0" + aTier, - "Crop Manager (" + GT_Values.VN[aTier] + ")", - aTier, - 21, - aDescription); - } - - public GT_MetaTileEntity_CropHarvestor(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 21, aDescription, aTextures); - } - - @Override - public boolean isTransformerUpgradable() { - return true; - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isInputFacing(ForgeDirection side) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public long maxAmperesIn() { - return 8; - } - - @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * (this.mTier * GT_Values.V[this.mTier]); - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public int getCapacity() { - return 32000 * this.mTier; - } - - @Override - public int getTankPressure() { - return -100; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_CropHarvestor(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public int getSizeInventory() { - return 21; - } - - private static int getRange(int aTier) { - return switch (aTier) { - case 1 -> 1; - case 2 -> 5; - case 3 -> 9; - case 4 -> 13; - case 5 -> 17; - case 6 -> 21; - case 7 -> 25; - case 8 -> 29; - case 9 -> 33; - default -> 0; - }; - } - - private HashSet mCropCache = new HashSet<>(); - private boolean mInvalidCache = false; - - public boolean doesInventoryHaveSpace() { - for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { - if (this.mInventory[i] == null || this.mInventory[i].stackSize < 64) { - return true; - } - } - return false; - } - - public long powerUsage() { - return this.maxEUInput() / 8; - } - - public long powerUsageSecondary() { - return this.maxEUInput() / 32; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (!getBaseMetaTileEntity().isServerSide() || !getBaseMetaTileEntity().isAllowedToWork() - || (!getBaseMetaTileEntity().hasWorkJustBeenEnabled() && aTick % 100 != 0)) return; - - if (this.getBaseMetaTileEntity() - .getUniversalEnergyStored() < getMinimumStoredEU()) return; - - int aTileX = this.getBaseMetaTileEntity() - .getXCoord(); - int aTileY = this.getBaseMetaTileEntity() - .getXCoord(); - int aTileZ = this.getBaseMetaTileEntity() - .getXCoord(); - - int aRadius = 10 + getRange(this.mTier); - int aSide = (aRadius - 1) / 2; - Map aAllDrops = new ItemStackMap<>(true); - - if (this.mCropCache.isEmpty() || aTick % 1200 == 0 || this.mInvalidCache) { - if (!this.mCropCache.isEmpty()) { - this.mCropCache.clear(); - } - // Logger.INFO("Looking for crops."); - for (int y = -2; y <= 2; y++) { - for (int x = (-aSide); x <= aSide; x++) { - for (int z = (-aSide); z <= aSide; z++) { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); - if (tTileEntity != null && tTileEntity instanceof ICropTile tCrop) { - this.mCropCache.add(tCrop); - } - } - } - } - } - - // Process Cache - if (!doesInventoryHaveSpace()) return; - - for (ICropTile tCrop : this.mCropCache) { - if (tCrop == null) { - this.mInvalidCache = true; - break; - } - CropCard aCrop = tCrop.getCrop(); - if (aCrop == null) continue; - - if (this.mModeAlternative) processSecondaryFunctions(tCrop); - if (!this.mHarvestEnabled) continue; - - if (aCrop.canBeHarvested(tCrop) && tCrop.getSize() == aCrop.getOptimalHavestSize(tCrop)) { - if (!getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsage(), true)) continue; - ItemStack[] aHarvest = tCrop.harvest_automated(true); - if (aHarvest == null) continue; - - for (ItemStack aStack : aHarvest) { - if (!ItemUtils.checkForInvalidItems(aStack)) continue; - if (this.mTier * 5 > MathUtils.randInt(1, 100)) { - aStack.stackSize += Math.floor(tCrop.getGain() / 10); - Logger.INFO("Bonus output given for " + aCrop.displayName()); - } - Logger.INFO("Harvested " + aCrop.displayName()); - aAllDrops.merge(aStack, aStack.stackSize, Integer::sum); - } - } - } - - if (aAllDrops.isEmpty()) return; - - Logger.INFO("Handling " + aAllDrops.size() + " Harvests"); - - for (var dropEntry : aAllDrops.entrySet()) { - ItemStack dropItem = dropEntry.getKey(); - int dropAmount = dropEntry.getValue(); - - // how this can happen, idk - if (dropItem == null) continue; - - for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory() && dropAmount > 0; i++) { - ItemStack invStack = mInventory[i]; - - // If the slot is empty, create a new stack for the drop item, else check if it is the same as the drop - // and merge if possible - if (invStack == null || GT_Utility.isStackInvalid(invStack) || invStack.stackSize == 0) { - int stackSize = Math.min(dropAmount, dropItem.getMaxStackSize()); - getBaseMetaTileEntity().setInventorySlotContents(i, GT_Utility.copyAmount(stackSize, dropItem)); - dropAmount -= stackSize; - } else if (GT_Utility.areStacksEqual(invStack, dropItem)) { - int space = Math.min(invStack.getMaxStackSize(), getInventoryStackLimit()) - invStack.stackSize; - if (dropAmount <= space) { - // if the drop amount fits - getBaseMetaTileEntity().addStackToSlot(i, invStack, dropAmount); - dropAmount = 0; - } else { - // fill the slot - getBaseMetaTileEntity().addStackToSlot(i, invStack, space); - dropAmount -= space; - } - } - } - } - } - - public boolean hasFertilizer() { - for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { - if (this.mInventory[i] != null) { - return true; - } - } - return false; - } - - public boolean consumeFertilizer(boolean aSimulate) { - if (hasFertilizer()) { - for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { - if (this.mInventory[i] != null) { - consume(i, 1, aSimulate); - return true; - } - } - } - return false; - } - - public boolean hasWeedEX() { - for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { - if (this.mInventory[i] != null) { - return true; - } - } - return false; - } - - public boolean consumeWeedEX(boolean aSimulate) { - if (hasWeedEX()) { - for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { - if (this.mInventory[i] != null) { - damage(i, 1, aSimulate); - return true; - } - } - } - return false; - } - - public void processSecondaryFunctions(ICropTile aCrop) { - if (!this.mModeAlternative) { - return; - } - if (hasFertilizer() && consumeFertilizer(true) - && this.getBaseMetaTileEntity() - .getUniversalEnergyStored() >= getMinimumStoredEU() - && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) - && applyFertilizer(aCrop)) { - if (consumeFertilizer(false)) { - // Logger.INFO("Consumed Fert."); - } - } - if (this.getFluidAmount() > 0 && this.getBaseMetaTileEntity() - .getUniversalEnergyStored() >= getMinimumStoredEU() - && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) - && applyHydration(aCrop)) { - // Logger.INFO("Consumed Water."); - } - if (hasWeedEX() && consumeWeedEX(true) - && this.getBaseMetaTileEntity() - .getUniversalEnergyStored() >= getMinimumStoredEU() - && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) - && applyWeedEx(aCrop)) { - if (consumeWeedEX(false)) { - // Logger.INFO("Consumed Weed-EX."); - } - } - } - - public boolean applyWeedEx(ICropTile aCrop) { - if (aCrop.getWeedExStorage() < 150) { - aCrop.setWeedExStorage(aCrop.getWeedExStorage() + 50); - boolean triggerDecline; - triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; - if (aCrop.getCrop() != null && aCrop.getCrop() - .isWeed(aCrop) && aCrop.getWeedExStorage() >= 75 && triggerDecline) { - switch (aCrop.getWorld().rand.nextInt(5)) { - case 0: - if (aCrop.getGrowth() > 0) { - aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); - } - case 1: - if (aCrop.getGain() > 0) { - aCrop.setGain((byte) (aCrop.getGain() - 1)); - } - default: - if (aCrop.getResistance() > 0) { - aCrop.setResistance((byte) (aCrop.getResistance() - 1)); - } - } - } - return true; - } else { - return false; - } - } - - public boolean applyFertilizer(ICropTile aCrop) { - if (aCrop.getNutrientStorage() >= 100) { - return false; - } else { - // Logger.INFO("Current Nutrient: "+aCrop.getNutrientStorage()+" for "+aCrop.getCrop().displayName()); - aCrop.setNutrientStorage(aCrop.getNutrientStorage() + 100); - return true; - } - } - - public boolean applyHydration(ICropTile aCrop) { - if (aCrop.getHydrationStorage() >= 200 || this.getFluidAmount() == 0) { - // Logger.INFO("Hydration Max"); - return false; - } else { - int apply = 200 - aCrop.getHydrationStorage(); - if (this.getFluidAmount() >= 0) { - int drain = 0; - if (this.getFluidAmount() >= apply) { - drain = apply; - } else { - drain = this.getFluidAmount(); - } - this.mFluid.amount -= drain; - if (this.mFluid.amount <= 0) { - this.mFluid = null; - } - // Logger.INFO("Did Hydrate"); - aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); - return true; - } else { - // Logger.INFO("No water?"); - return false; - } - } - } - - public boolean consume(int aSlot, int amount, boolean simulate) { - ItemStack stack = this.mInventory[aSlot]; - if (stack != null && stack.stackSize >= amount) { - int currentAmount = Math.min(amount, stack.stackSize); - amount -= currentAmount; - if (!simulate) { - if (stack.stackSize == currentAmount) { - this.mInventory[aSlot] = null; - } else { - stack.stackSize -= currentAmount; - } - } else { - return amount >= 0; - } - return true; - } - return false; - } - - public ItemStack damage(int aSlot, int amount, boolean simulate) { - ItemStack ret = null; - int damageApplied = 0; - ItemStack stack = this.mInventory[aSlot]; - Item item = stack.getItem(); - if (stack != null && item.isDamageable() - && (ret == null || stack.getItem() == ret.getItem() && ItemStack.areItemStackTagsEqual(stack, ret))) { - if (simulate) { - stack = stack.copy(); - } - int maxDamage = DamageHandler.getMaxDamage(stack); - while (amount > 0 && stack.stackSize > 0) { - int currentAmount = Math.min(amount, maxDamage - DamageHandler.getDamage(stack)); - DamageHandler.damage(stack, currentAmount, null); - damageApplied += currentAmount; - amount -= currentAmount; - if (DamageHandler.getDamage(stack) >= maxDamage) { - --stack.stackSize; - DamageHandler.setDamage(stack, 0); - } - - if (ret == null) { - ret = stack.copy(); - } - } - if (stack.stackSize == 0 && !simulate) { - this.mInventory[aSlot] = null; - } - } - - if (ret != null) { - int i = DamageHandler.getMaxDamage(ret); - ret.stackSize = damageApplied / i; - DamageHandler.setDamage(ret, damageApplied % i); - } - return ret; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - if (aStack != null) { - if (aStack.getItem() - .getUnlocalizedName() - .equals("ic2.itemFertilizer")) { - return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; - } else if (aStack.getItem() - .getUnlocalizedName() - .equals("ic2.itemWeedEx")) { - return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; - } - } - return false; - } - - @Override - public String[] getDescription() { - int aRadius = 10 + getRange(this.mTier); - int aSide = (aRadius - 1) / 2; - return ArrayUtils.addAll( - this.mDescriptionArray, - "Secondary mode can Hydrate/Fertilize/Weed-EX", - "Consumes " + powerUsage() + "eu per harvest", - "Consumes " + powerUsageSecondary() + "eu per secondary operation", - "Can harvest 2 block levels above and below itself", - "Radius: " + aSide + " blocks each side (" + aRadius + "x3x" + aRadius + ")", - "Has " + (this.mTier * 5) + "% chance for extra drops", - "Holds " + this.getCapacity() + "L of Water", - CORE.GT_Tooltip.get()); - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return true; - } - - /* - * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == - * aFacing) return 118+(aRedstone?8:0); if (GT_Utility.getOppositeSide(aSide) == aFacing) return - * 113+(aRedstone?8:0); int tIndex = 128+(aRedstone?8:0); switch (aFacing) { case 0: return tIndex+64; case 1: - * return tIndex+32; case 2: switch (aSide) { case 0: return tIndex+32; case 1: return tIndex+32; case 4: return - * tIndex+16; case 5: return tIndex+48; } case 3: switch (aSide) { case 0: return tIndex+64; case 1: return - * tIndex+64; case 4: return tIndex+48; case 5: return tIndex+16; } case 4: switch (aSide) { case 0: return - * tIndex+16; case 1: return tIndex+16; case 2: return tIndex+48; case 3: return tIndex+16; } case 5: switch (aSide) - * { case 0: return tIndex+48; case 1: return tIndex+48; case 2: return tIndex+16; case 3: return tIndex+48; } } - * return tIndex; } - */ - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getBack(i); - rTextures[7][i + 1] = this.getBottom(i); - rTextures[8][i + 1] = this.getTop(i); - rTextures[9][i + 1] = this.getSides(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) { - return this.mTextures[3][aColorIndex + 1]; - } else { - return this.mTextures[4][aColorIndex + 1]; - } - /* - * return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) - * ? 1 : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - */ - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mModeAlternative", this.mModeAlternative); - aNBT.setBoolean("mHarvestEnabled", this.mHarvestEnabled); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mModeAlternative = aNBT.getBoolean("mModeAlternative"); - if (aNBT.hasKey("mHarvestEnabled")) { - this.mHarvestEnabled = aNBT.getBoolean("mHarvestEnabled"); - } - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new CycleButtonWidget().setToggle(() -> mModeAlternative, val -> mModeAlternative = val) - .setTexture(GTPP_UITextures.OVERLAY_BUTTON_HARVESTER_MODE) - .addTooltip(0, "Enable Hydration/Fertilizing/Weed-EX") - .addTooltip(1, "Disable Hydration/Fertilizing/Weed-EX") - .setBackground(GT_UITextures.BUTTON_STANDARD) - .setPos(47, 63) - .setSize(18, 18)); - builder.widget( - new CycleButtonWidget().setToggle(() -> mHarvestEnabled, val -> mHarvestEnabled = val) - .setTexture(GTPP_UITextures.OVERLAY_BUTTON_HARVESTER_TOGGLE) - .addTooltip(0, "Enable Harvest") - .addTooltip(1, "Disable Harvest") - .setBackground(GT_UITextures.BUTTON_STANDARD) - .setPos(67, 63) - .setSize(18, 18)); - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 2) - .startFromSlot(SLOT_WEEDEX_1) - .endAtSlot(SLOT_WEEDEX_2) - .applyForWidget( - widget -> widget.setFilter( - stack -> stack != null && stack.getItem() - .getUnlocalizedName() - .equals("ic2.itemWeedEx")) - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_WEED_EX)) - .build() - .setPos(7, 13)) - .widget( - SlotGroup.ofItemHandler(inventoryHandler, 2) - .startFromSlot(SLOT_FERT_1) - .endAtSlot(SLOT_FERT_4) - .applyForWidget( - widget -> widget.setFilter( - stack -> stack != null && stack.getItem() - .getUnlocalizedName() - .equals("ic2.itemFertilizer")) - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_FERTILIZER)) - .build() - .setPos(7, 31)) - .widget( - SlotGroup.ofItemHandler(inventoryHandler, 6) - .startFromSlot(SLOT_OUTPUT_START) - .endAtSlot(SLOT_OUTPUT_START + 6 * 3) - .canInsert(false) - .build() - .setPos(61, 7)); - builder - .widget( - new ProgressBar() - .setTexture(GTPP_UITextures.PROGRESSBAR_BOILER_EMPTY, GT_UITextures.PROGRESSBAR_BOILER_WATER, 54) - .setDirection(ProgressBar.Direction.UP) - .setProgress(() -> (float) getFluidAmount() / getCapacity()) - .setSynced(false, false) - .dynamicTooltip( - () -> Collections.singletonList("Water: " + getFluidAmount() + "L / " + getCapacity() + "L")) - .setPos(47, 7) - .setSize(10, 54)) - .widget(new FakeSyncWidget.FluidStackSyncer(this::getDrainableStack, this::setDrainableStack)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java deleted file mode 100644 index 4bc9004944..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ /dev/null @@ -1,889 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import static gregtech.api.enums.GT_Values.V; - -import java.util.Collections; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -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 gregtech.api.enums.Materials; -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.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.items.ID_MetaTool_01; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.item.general.ItemAirFilter; -import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_BasicMachine { - - public int mPollutionReduction = 0; - protected int mBaseEff = 2500; - protected int mOptimalAirFlow = 0; - protected boolean mHasPollution = false; - protected int SLOT_ROTOR = 5; - protected int SLOT_FILTER = 6; - protected static boolean mPollutionEnabled = true; - - protected boolean mSaveRotor = false; - - public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - 2, - "Making sure you don't live in Gwalior - Uses 2A", - 3, - 0, - new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - } - - public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, 2, aDescription, aTextures, 2, 0); - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaAtmosphericReconditioner(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public String[] getDescription() { - - boolean highTier = this.mTier >= 7; - - String[] A = ArrayUtils.addAll( - this.mDescriptionArray, - highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", - highTier ? "If these chunks are not loaded, they will be ignored" : "", - "Requires a turbine rotor and an Air Filter [T1/T2] to run.", - "The turbine rotor must be manually inserted/replaced", - "Can be configured with a soldering iron to change modes", - "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", - "High Efficiency: Removes full pollution, Turbine takes 100% dmg", - "Turbine Rotor will not break in LE mode", - "Insert an equal tier Conveyor Module to enable automation"); - if (!mPollutionEnabled) { - String[] B = new String[] { "===============================================", - "Pollution is disabled, scrubbers will now have a bonus use", - "They are now able to remove ALL lingering pollution as GT ignores it", "and it will linger forever!", - "===============================================", }; - A = ArrayUtils.addAll(A, B); - } - return A; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); - aNBT.setBoolean("mSaveRotor", mSaveRotor); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow"); - this.mSaveRotor = aNBT.getBoolean("mSaveRotor"); - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 2; - } - - @Override - public long maxEUStore() { - return V[mTier] * 256; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - - // Get Current Pollution Amount. - int mCurrentPollution = getCurrentChunkPollution(); - boolean isIdle = true; - - // Get Inventory Item - ItemStack stackRotor = this.mInventory[SLOT_ROTOR]; - ItemStack stackFilter = this.mInventory[SLOT_FILTER]; - - // Power Drain - long drainEU = maxEUInput() * maxAmperesIn(); - if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU) { - if (aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)) { - isIdle = false; - } else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - } else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU / 4) { - if (aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU / 4), false)) { - isIdle = false; - } else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - } else { - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - - // Only try once/sec. - if (!isIdle && aTick % 20L == 0L) { - - for (int i = 0; i < this.mInventory.length; i++) { - ItemStack aSlotContent = this.mInventory[i]; - if (aSlotContent != null) { - Logger.INFO("Found " + aSlotContent.getDisplayName() + " in slot " + i); - } - } - - for (int i = 0; i < this.mInventory.length; i++) { - if (hasRotor(this.mInventory[i])) { - Logger.INFO("Found Rotor in slot " + i); - break; - } - } - for (int i = 0; i < this.mInventory.length; i++) { - if (hasAirFilter(this.mInventory[i])) { - Logger.INFO("Found Filter in slot " + i); - break; - } - } - - // Check if machine can work. - if ((aBaseMetaTileEntity.isAllowedToWork())) { - Logger.INFO("Can work."); - - // Enable machine animation/graphic - if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution) { - if (!this.getBaseMetaTileEntity() - .isActive()) { - Logger.INFO("Set Active."); - aBaseMetaTileEntity.setActive(true); - } - } else if (!this.mHasPollution || mCurrentPollution <= 0 - || stackRotor == null - || stackFilter == null - || !hasRotor(stackRotor) - || !hasAirFilter(stackFilter)) { - if (!this.getBaseMetaTileEntity() - .isActive()) { - Logger.INFO("Set Inactive."); - aBaseMetaTileEntity.setActive(false); - this.sendSound((byte) -122); - } - } - - // If Active. - if (aBaseMetaTileEntity.isActive()) { - Logger.INFO("Doing something."); - - // Do nothing if there is no pollution. - if (this.mHasPollution && mCurrentPollution > 0) { - Logger - .INFO("Has Pollution? " + mHasPollution + ", Current Pollution: " + mCurrentPollution); - - // Only check every 30s. - if (!isIdle && aTick % (20L * 30) == 0L) { - mPollutionEnabled = PollutionUtils.isPollutionEnabled(); - // Clear out pollution if it's disabled, because I am a nice gal. - if (!PollutionUtils.isPollutionEnabled()) { - PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); - } - } - - // Use a Turbine - if (hasRotor(stackRotor) && hasAirFilter(stackFilter)) { - Logger.INFO("Found Turbine."); - - mBaseEff = getBaseEfficiency(stackRotor); - mOptimalAirFlow = getOptimalAirFlow(stackRotor); - - // Make sure we have a valid Turbine and Eff/Airflow - if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0) { - // Utils.LOG_WARNING("Pollution Cleaner [5]"); - - // Log Debug information. - Logger.INFO("mBaseEff[1]:" + mBaseEff); - Logger.INFO("mOptimalAirFlow[1]:" + mOptimalAirFlow); - - // Calculate The Voltage we are running - long tVoltage = drainEU; - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - // Check Sides for Air, - // More air means more pollution processing. - int mAirSides = getFreeSpaces(); - - int reduction = 0; - - // If no sides are free, how will you process the atmosphere? - if (mAirSides > 0) { - reduction += (((Math.max((tTier - 2), 1) * 2) * 50) * mAirSides); // Was - // originally - // *100 - Logger.INFO("mPollutionReduction[1]:" + reduction); - - // I stole this code - reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) - * mAirSides - * Math.max((tTier - 2), 1); - Logger.INFO("reduction[2]:" + reduction); - reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); - Logger.INFO("reduction[3]:" + reduction); - - mPollutionReduction = reduction; - - // Set a temp to remove variable to aleviate duplicate code. - int toRemove = 0; - - Logger.INFO("mCurrentPollution[4]:" + mCurrentPollution); - Logger.INFO("mCurrentPollution[5]:" + reduction); - if (reduction <= mCurrentPollution) { - // Clean some Air. - toRemove = reduction; - } else { - // Makes sure we don't get negative pollution. - toRemove = mCurrentPollution; - } - - toRemove = toRemove / 2; - Logger.INFO("mCurrentPollution[6]:" + toRemove); - - // We are good to clean - if (toRemove > 0) { - if (damageTurbineRotor() && damageAirFilter()) { - Logger.INFO("Removing " + toRemove + " pollution"); - removePollution(mSaveRotor ? (toRemove / 2) : toRemove); - Logger.INFO("mNewPollution[4]:" + getCurrentChunkPollution()); - } else { - Logger.INFO("Could not damage turbine rotor or Air Filter."); - aBaseMetaTileEntity.setActive(false); - } - } // End of pollution removal block. - } // End of valid air sides block. - } // End of valid toolstats block. - } // End of correct inventory item block. - else { - // Utils.LOG_WARNING("Wrong Tool metaitem Found."); - } - } - } else if (!aBaseMetaTileEntity.isActive()) { - return; - } - } // End of can work block. - else { // Disable Machine. - // aBaseMetaTileEntity.setActive(false); - } - } // End of 1/sec action block. - else { - - if (hasRotor(stackRotor) && hasAirFilter(stackFilter) - && this.mHasPollution - && !isIdle - && aBaseMetaTileEntity.isAllowedToWork()) { - aBaseMetaTileEntity.setActive(true); - } else if (isIdle || !this.mHasPollution - || mCurrentPollution <= 0 - || stackRotor == null - || stackFilter == null - || !hasRotor(stackRotor) - || !hasAirFilter(stackFilter)) { - aBaseMetaTileEntity.setActive(false); - } - } - if (this.getBaseMetaTileEntity() - .isActive()) { - if (MathUtils.randInt(0, 5) <= 2) { - this.sendSound((byte) -120); - } - } - } // End of is serverside block. - } - - public int getCurrentChunkPollution() { - int mCurrentChunkPollution = 0; - if (this.mTier < 7) { - mCurrentChunkPollution = PollutionUtils.getPollution(getBaseMetaTileEntity()); - } else { - AutoMap aSurrounding = new AutoMap<>(); - World aWorld = this.getBaseMetaTileEntity() - .getWorld(); - int xPos = this.getBaseMetaTileEntity() - .getXCoord(); - int zPos = this.getBaseMetaTileEntity() - .getZCoord(); - Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); - Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); - Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); - Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); - Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); - Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); - Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); - Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); - Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); - aSurrounding.put(a1); - aSurrounding.put(a2); - aSurrounding.put(a3); - aSurrounding.put(b1); - aSurrounding.put(b2); - aSurrounding.put(b3); - aSurrounding.put(c1); - aSurrounding.put(c2); - aSurrounding.put(c3); - for (Chunk r : aSurrounding) { - mCurrentChunkPollution += getPollutionInChunk(r); - } - } - if (mCurrentChunkPollution > 0) { - mHasPollution = true; - } else { - mHasPollution = false; - } - return mCurrentChunkPollution; - } - - public int getPollutionInChunk(Chunk aChunk) { - int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); - if (mCurrentChunkPollution > 0) { - mHasPollution = true; - } else { - mHasPollution = false; - } - return mCurrentChunkPollution; - } - - public boolean hasRotor(ItemStack rotorStack) { - if (rotorStack != null) { - if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { - // Logger.INFO("Found Basic Turbine Rotor."); - return true; - } else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 - && rotorStack.getItemDamage() <= 179) { - // Logger.INFO("Found Turbine Rotor."); - return true; - } else { - // Logger.INFO("Found: "+rotorStack.getDisplayName()+":"+rotorStack.getItemDamage()); - } - } - // Logger.INFO("Found No Turbine Rotor."); - return false; - } - - public boolean damageTurbineRotor() { - try { - - boolean creativeRotor = false; - ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; - if (rotorStack == null) { - return false; - } else if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { - long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); - // Remove broken Filter - if (rotorStack.getItemDamage() == 0 && currentUse >= 2000 - 10) { - Logger.INFO("Depleting ItemBasicScrubberTurbine T1"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } else if (rotorStack.getItemDamage() == 1 && currentUse >= 4000 - 10) { - Logger.INFO("Depleting ItemBasicScrubberTurbine T2"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } else if (rotorStack.getItemDamage() == 2 && currentUse >= 6000 - 10) { - Logger.INFO("Depleting ItemBasicScrubberTurbine T3"); - this.mInventory[this.SLOT_FILTER] = null; - return false; - } else { - // Do Damage - Logger.INFO("Damaging ItemBasicScrubberTurbine"); - ItemBasicScrubberTurbine.setFilterDamage(rotorStack, currentUse + 10); - Logger.INFO("Rotor Damage: " + currentUse); - return true; - } - } else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { - Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); - Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); - if (t1 == Materials._NULL && t2 == Materials._NULL) { - Logger.INFO("Found creative rotor."); - creativeRotor = true; - } - } else { - Logger.INFO("Bad item in rotor slot."); - return false; - } - - if (mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 - && ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]) - .getSpeedMultiplier() > 0 - && GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed > 0) { - - long damageValue = (long) Math - .floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); - double fDam = Math - .floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); - damageValue -= fDam; - - // Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); - /* - * Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); Materials - * M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); - * Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]"); - */ - - // Damage Rotor - // int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); - long rotorDamage = creativeRotor ? 0 - : GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - long rotorDurabilityMax = creativeRotor ? Integer.MAX_VALUE - : GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); - long rotorDurability = (rotorDurabilityMax - rotorDamage); - Logger.INFO( - "Rotor Damage: " + rotorDamage - + " | Max Durability: " - + rotorDurabilityMax - + " | " - + " Remaining Durability: " - + rotorDurability); - if (rotorDurability >= damageValue) { - - if (!mSaveRotor) { - Logger.INFO("Damaging Rotor."); - - if (!creativeRotor) GT_ModHandler - .damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); - - long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - if (tempDur < rotorDurabilityMax) { - return true; - } else { - rotorDurability = 0; - } - } else { - Logger.INFO("Damaging Rotor."); - if (rotorDurability > 1000) { - if (!creativeRotor) GT_ModHandler - .damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue / 2, 0, null); - long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - if (tempDur < rotorDurabilityMax) { - return true; - } else { - rotorDurability = 0; - } - } - } - } - - if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { - Logger.INFO("Destroying Rotor."); - this.mInventory[this.SLOT_ROTOR] = null; - return false; - } else if (rotorDurability <= 0 && mSaveRotor) { - Logger.INFO("Saving Rotor."); - return false; - } - - } else { - Logger.INFO("Bad Rotor."); - return false; - } - } catch (Throwable t) { - t.printStackTrace(); - } - return false; - } - - public int getFreeSpaces() { - int mAir = 0; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - if (aBaseMetaTileEntity.getAirOffset(1, 0, 0)) { - mAir++; - } - if (aBaseMetaTileEntity.getAirOffset(-1, 0, 0)) { - mAir++; - } - if (aBaseMetaTileEntity.getAirOffset(0, 0, 1)) { - mAir++; - } - if (aBaseMetaTileEntity.getAirOffset(0, 0, -1)) { - mAir++; - } - if (aBaseMetaTileEntity.getAirOffset(0, 1, 0)) { - mAir++; - } - if (aBaseMetaTileEntity.getAirOffset(0, -1, 0)) { - mAir++; - } - return mAir; - } - - public boolean removePollution(int toRemove) { - - if (this == null || this.getBaseMetaTileEntity() == null - || this.getBaseMetaTileEntity() - .getWorld() == null) { - return false; - } - - if (this.mTier < 7) { - int startPollution = getCurrentChunkPollution(); - Logger.INFO("Current Chunk Pollution: " + startPollution); - PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); - int after = getCurrentChunkPollution(); - Logger.INFO("Current Chunk Pollution: " + after); - return (after < startPollution); - } else { - int chunksWithRemoval = 0; - int totalRemoved = 0; - AutoMap aSurrounding = new AutoMap<>(); - Chunk aThisChunk = this.getBaseMetaTileEntity() - .getWorld() - .getChunkFromBlockCoords( - this.getBaseMetaTileEntity() - .getXCoord(), - this.getBaseMetaTileEntity() - .getZCoord()); - int mainChunkX = aThisChunk.xPosition; - int mainChunkZ = aThisChunk.zPosition; - - World aWorld = this.getBaseMetaTileEntity() - .getWorld(); - int xPos = this.getBaseMetaTileEntity() - .getXCoord(); - int zPos = this.getBaseMetaTileEntity() - .getZCoord(); - - Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); - Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); - Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); - Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); - Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); - Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); - Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); - Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); - Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); - - aSurrounding.put(a1); - aSurrounding.put(a2); - aSurrounding.put(a3); - aSurrounding.put(b1); - aSurrounding.put(b2); - aSurrounding.put(b3); - aSurrounding.put(c1); - aSurrounding.put(c2); - aSurrounding.put(c3); - - for (Chunk r : aSurrounding) { - if (!r.isChunkLoaded) { - continue; - } - - int startPollution = getPollutionInChunk(r); - if (startPollution == 0) { - continue; - } - - Logger.INFO( - "Trying to remove pollution from chunk " + r.xPosition - + ", " - + r.zPosition - + " | " - + startPollution); - int after = 0; - boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); - - int removal = Math.max(0, !isMainChunk ? (toRemove / 4) : toRemove); - if (removePollution(r, removal)) { - chunksWithRemoval++; - after = getPollutionInChunk(r); - } else { - after = 0; - } - if (startPollution - after > 0) { - totalRemoved += (startPollution - after); - } - Logger.INFO( - "Removed " + (startPollution - after) - + " pollution from chunk " - + r.xPosition - + ", " - + r.zPosition - + " | " - + after); - } - return totalRemoved > 0 && chunksWithRemoval > 0; - } - } - - public boolean removePollution(Chunk aChunk, int toRemove) { - int before = getCurrentChunkPollution(); - PollutionUtils.removePollution(aChunk, toRemove); - int after = getCurrentChunkPollution(); - return (after < before); - } - - public boolean hasAirFilter(ItemStack filter) { - if (filter == null) { - return false; - } - return filter.getItem() instanceof ItemAirFilter; - } - - public boolean damageAirFilter() { - ItemStack filter = this.mInventory[this.SLOT_FILTER]; - if (filter == null) { - return false; - } - - boolean creativeRotor = false; - ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; - if (rotorStack != null) { - if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { - Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); - Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); - if (t1 == Materials._NULL && t2 == Materials._NULL) { - creativeRotor = true; - } - } - } - - if (creativeRotor) { - return true; - } - - if (filter.getItem() instanceof ItemAirFilter) { - - long currentUse = ItemAirFilter.getFilterDamage(filter); - - // Remove broken Filter - if (filter.getItemDamage() == 0 && currentUse >= 50 - 1) { - this.mInventory[this.SLOT_FILTER] = null; - return false; - } else if (filter.getItemDamage() == 1 && currentUse >= 2500 - 1) { - this.mInventory[this.SLOT_FILTER] = null; - return false; - } else { - // Do Damage - ItemAirFilter.setFilterDamage(filter, currentUse + 1); - Logger.INFO("Filter Damage: " + currentUse); - return true; - } - } - return false; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { - if (aIndex == SLOT_FILTER) { - if (aStack.getItem() instanceof ItemAirFilter) { - Logger.INFO("Inserting Air Filter into " + aIndex); - return true; - } - } - if (aIndex == SLOT_ROTOR) { - if (this.mInventory[7] != null) { - Logger.INFO("Found conveyor, can automate turbines. Inserting into " + aIndex); - if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 - && aStack.getItemDamage() <= 179) { - return true; - } - } - } - return false; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - if (aIndex == -120) { - GT_Utility - .doSoundAtClient(SoundResource.IC2_TOOLS_BATTERY_USE, MathUtils.randInt(5, 50), 0.05F, aX, aY, aZ); - } else { - super.doSound((byte) 0, aX, aY, aZ); - } - } - - @Override - public String[] getInfoData() { - AutoMap aTooltipSuper = new AutoMap<>(); - for (String s : super.getInfoData()) { - aTooltipSuper.put(s); - } - int mAirSides = getFreeSpaces(); - int reduction = 0; - - try { - long tVoltage = maxEUInput(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - reduction += (((Math.max((tTier - 2), 1) * 2) * 50) * mAirSides); - reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) * mAirSides - * Math.max((tTier - 2), 1); - reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); - - aTooltipSuper.put("Maximum pollution removed per second: " + reduction); - } catch (Throwable t) { - aTooltipSuper.put("Maximum pollution removed per second: " + mPollutionReduction); - } - aTooltipSuper.put("Air Sides: " + mAirSides); - - String[] mBuiltOutput = new String[aTooltipSuper.size()]; - int aIndex = 0; - for (String i : aTooltipSuper) { - mBuiltOutput[aIndex++] = i; - } - - return mBuiltOutput; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { - if (side.offsetY != 0) { - return false; - } - return super.allowCoverOnSide(side, aCoverID); - } - - @Override - public ITexture[] getTopFacingInactive(byte aColor) { - return super.getTopFacingInactive(aColor); - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); - aNBT.setBoolean("mSaveRotor", mSaveRotor); - super.setItemNBT(aNBT); - } - - private static ItemStack[] sGregTurbines; - - public static ItemStack getTieredTurbine(int aTier) { - if (sGregTurbines == null) { - sGregTurbines = new ItemStack[3]; - sGregTurbines[0] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01") - .getToolWithStats(ID_MetaTool_01.TURBINE_SMALL.ID, 1, Materials.Iron, Materials.Iron, null); - sGregTurbines[1] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01") - .getToolWithStats(ID_MetaTool_01.TURBINE_SMALL.ID, 1, Materials.Bronze, Materials.Bronze, null); - sGregTurbines[2] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01") - .getToolWithStats(ID_MetaTool_01.TURBINE_SMALL.ID, 1, Materials.Steel, Materials.Steel, null); - } else { - return sGregTurbines[aTier]; - } - - return null; - } - - public int getBaseEfficiency(ItemStack aStackRotor) { - if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { - return getBaseEfficiency(getTieredTurbine(aStackRotor.getItemDamage())); - } - return (int) ((50.0F - + (10.0F * ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolCombatDamage(aStackRotor))) * 100); - } - - public int getOptimalAirFlow(ItemStack aStackRotor) { - if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { - return getOptimalAirFlow(getTieredTurbine(aStackRotor.getItemDamage())); - } - return (int) Math.max( - Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolStats(aStackRotor) - .getSpeedMultiplier() * GT_MetaGenerated_Tool.getPrimaryMaterial(aStackRotor).mToolSpeed * 50); - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget(new SlotWidget(inventoryHandler, SLOT_ROTOR).setFilter(stack -> { - if (stack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - return stack.getItem() instanceof GT_MetaGenerated_Tool && stack.getItemDamage() >= 170 - && stack.getItemDamage() <= 179; - }) - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_TURBINE) - .setPos(52, 24)) - .widget( - new SlotWidget(inventoryHandler, SLOT_FILTER) - .setFilter(stack -> stack.getItem() instanceof ItemAirFilter) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_RECYCLE) - .setPos(106, 24)) - .widget( - new SlotWidget(inventoryHandler, 7) - .setFilter(stack -> GT_Utility.areStacksEqual(stack, CI.getConveyor(mTier, 1), true)) - .setPos(124, 62)); - builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_INFORMATION) - .dynamicTooltip(() -> Collections.singletonList("Reduction: " + mPollutionReduction + "/s")) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> mPollutionReduction, val -> mPollutionReduction = val), - builder, - (widget, val) -> widget.notifyTooltipChange()) - .setPos(163, 5) - .setSize(7, 18)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java deleted file mode 100644 index d7b6b8fffd..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java +++ /dev/null @@ -1,458 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaPollutionCreator extends GregtechMetaTileEntity { - - int mCurrentPollution; - int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; - private int mArrayPos = 0; - private int mTickTimer = 0; - private int mSecondTimer = 0; - - public GregtechMetaPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaPollutionCreator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "A useful debug machine to create pollution.", CORE.GT_Tooltip.get() }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (pollutionMultiplier > 99) { - pollutionMultiplier = 1; - } else { - pollutionMultiplier++; - } - PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now " + pollutionMultiplier + "."); - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPollutionCreator( - this.mName, - this.mTier, - this.mDescription, - this.mTextures, - this.mInventory.length); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return 0; - } - - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyStored(); - } - - @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyCapacity(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - public int pollutionMultiplier = 1; - - private void showPollution(final World worldIn, final EntityPlayer playerIn) { - if (!PollutionUtils.isPollutionEnabled()) { - PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); - } else { - addPollution(); - PlayerUtils - .messagePlayer(playerIn, "This chunk now contains " + getCurrentChunkPollution() + " pollution."); - // PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" - // pollution."); - } - } - - private boolean addPollution() { - PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000 * pollutionMultiplier); - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - public int getCurrentChunkPollution() { - return getCurrentChunkPollution(this.getBaseMetaTileEntity()); - } - - public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { - return PollutionUtils.getPollution(aBaseMetaTileEntity); - } - - @Override - public String[] getInfoData() { - return new String[] { this.getLocalName(), "Current Pollution: " + this.mCurrentPollution, - "Average/10 minutes:" + getAveragePollutionOverLastTen() }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); - aNBT.setInteger("mAveragePollution", this.mAveragePollution); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); - this.mAveragePollution = aNBT.getInteger("mAveragePollution"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - if (this.getBaseMetaTileEntity() - .isServerSide()) { - if (this.mCurrentPollution == 0) { - this.mCurrentPollution = getCurrentChunkPollution(); - } - if (this.mArrayPos < 0 || this.mArrayPos > 9) { - this.mArrayPos = 0; - } - this.mTickTimer = 0; - } - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity() - .isServerSide()) { - // TickTimer - 20 times a second - this.mTickTimer++; - if (mTickTimer % 20 == 0) { - this.mCurrentPollution = getCurrentChunkPollution(); - } - } - } - - public int getAveragePollutionOverLastTen() { - int counter = 0; - int total = 0; - - for (int j : this.mAveragePollutionArray) { - if (j != 0) { - total += j; - counter++; - } - } - int returnValue = 0; - if (total > 0 && counter > 0) { - returnValue = (total / counter); - this.mAveragePollution = returnValue; - } else { - returnValue = getCurrentChunkPollution(); - } - // Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" - // |"); - return returnValue; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java deleted file mode 100644 index 92443d2658..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java +++ /dev/null @@ -1,502 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { - - int mCurrentPollution; - int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; - private int mArrayPos = 0; - private int mTickTimer = 0; - private int mSecondTimer = 0; - private long mRedstoneLevel = 0; - - public GregtechMetaPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaPollutionDetector(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Right click to check pollution levels.", - "Configure with screwdriver to set redstone output amount.", "Does not use power.", CORE.GT_Tooltip.get() }; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return side == facing - ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - /* - * @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final - * byte aFacing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { return - * this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 : side == facing.getOpposite() ? 1 : side == - * ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; } - */ - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPollutionDetector( - this.mName, - this.mTier, - this.mDescription, - this.mTextures, - this.mInventory.length); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return 0; - } - - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyStored(); - } - - @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyCapacity(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - private void showPollution(final World worldIn, final EntityPlayer playerIn) { - if (!PollutionUtils.isPollutionEnabled()) { - PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); - } else { - PlayerUtils.messagePlayer(playerIn, "This chunk contains " + getCurrentChunkPollution() + " pollution."); - PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: " + this.mRedstoneLevel); - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - public int getCurrentChunkPollution() { - return getCurrentChunkPollution(this.getBaseMetaTileEntity()); - } - - public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { - return PollutionUtils.getPollution(aBaseMetaTileEntity); - } - - @Override - public String[] getInfoData() { - return new String[] { this.getLocalName(), "Current Pollution: " + this.mCurrentPollution, - "Average/10 Sec: " + this.mAveragePollution, "Emit Redstone at pollution level: " + this.mRedstoneLevel }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); - aNBT.setInteger("mAveragePollution", this.mAveragePollution); - aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); - this.mAveragePollution = aNBT.getInteger("mAveragePollution"); - this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - // Only Calc server-side - if (!this.getBaseMetaTileEntity() - .isServerSide()) { - return; - } - // Emit Redstone - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - this.getBaseMetaTileEntity() - .setStrongOutputRedstoneSignal(side, (byte) 16); - } - this.markDirty(); - } else { - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - this.getBaseMetaTileEntity() - .setStrongOutputRedstoneSignal(side, (byte) 0); - } - this.markDirty(); - } - - // Do Math for stats - if (this.mTickTimer % 20 == 0) { - mCurrentPollution = this.getCurrentChunkPollution(); - if (mArrayPos > mAveragePollutionArray.length - 1) { - mArrayPos = 0; - } - mAveragePollutionArray[mArrayPos] = mCurrentPollution; - mAveragePollution = getAveragePollutionOverLastTen(); - mArrayPos++; - } - this.mTickTimer++; - } - - public int getAveragePollutionOverLastTen() { - return MathUtils.getIntAverage(mAveragePollutionArray); - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - if (side == this.getBaseMetaTileEntity() - .getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { - case 0 -> this.mRedstoneLevel -= 5000; - case 1 -> this.mRedstoneLevel += 5000; - case 2 -> this.mRedstoneLevel -= 50000; - case 3 -> this.mRedstoneLevel += 50000; - } - this.markDirty(); - GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); - } - - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - - @Override - public boolean allowGeneralRedstoneOutput() { - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { - this.markDirty(); - return true; - } - return false; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { - return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - } - - @Override - public void onMachineBlockUpdate() { - super.onMachineBlockUpdate(); - } - - @Override - public boolean hasSidedRedstoneOutputBehavior() { - if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { - this.markDirty(); - return true; - } - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java deleted file mode 100644 index a845982e8b..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_AutoChisel.java +++ /dev/null @@ -1,185 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.math.Pos2d; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; - -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.BasicUIProperties; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import team.chisel.carving.Carving; - -public class GregtechMetaTileEntity_AutoChisel extends GT_MetaTileEntity_BasicMachine { - - private ItemStack mInputCache; - private ItemStack mOutputCache; - - public GregtechMetaTileEntity_AutoChisel(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - 1, - "Chisels things, Gregtech style", - 1, - 1, - new ITexture[] { new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), - new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GT_RenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); - } - - public GregtechMetaTileEntity_AutoChisel(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AutoChisel(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - this.mDescriptionArray, - "What you want to chisel goes in slot 1", - "What you want to get goes in the special slot (bottom right)", - "If special slot is empty, first chisel result is used"); - } - - private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { - if (mInputCache != null && mOutputCache != null) { - if (GT_Utility.areStacksEqual(aStack, mInputCache) - && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { - return true; - } - } - // clear cache if it was invalid - if (aClearOnFailure) { - mInputCache = null; - mOutputCache = null; - } - return false; - } - - private void cacheItem(ItemStack mInputItem, ItemStack mOutputItem) { - mOutputCache = mOutputItem.copy(); - mInputCache = mInputItem.copy(); - } - - @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return hasValidCache(aStack, this.getSpecialSlot(), false) ? true - : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && hasChiselResults(aStack); - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { - List results = getItemsForChiseling(from); - for (ItemStack s : results) { - if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { - return true; - } - } - return false; - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean hasChiselResults(ItemStack from) { - List results = getItemsForChiseling(from); - return results.size() > 0; - } - - private static List getItemsForChiseling(ItemStack aStack) { - return Carving.chisel.getItemsForChiseling(aStack); - } - - private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { - ItemStack tOutput = null; - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { - tOutput = null; - } else { - tOutput = getItemsForChiseling(aInput).get(0); - } - return tOutput; - } - - @Override - public int checkRecipe() { - ItemStack tOutput = null; - ItemStack aInput = getInputAt(0); - ItemStack aTarget = getSpecialSlot(); - boolean tIsCached = hasValidCache(aInput, aTarget, true); - if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { - tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); - if (tOutput != null) { - tOutput = tOutput.copy(); - tOutput.stackSize = 1; - // We can chisel this - if (canOutput(tOutput)) { - getInputAt(0).stackSize -= 1; - calculateOverclockedNess(16, 20); - // In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - if (!tIsCached) { - cacheItem(ItemUtils.getSimpleStack(aInput, 1), ItemUtils.getSimpleStack(tOutput, 1)); - } - this.mOutputItems[0] = tOutput.copy(); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } else { - mOutputBlocked++; - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - } - } - return DID_NOT_FIND_RECIPE; - } - - private static final FallbackableUITexture progressBarTexture = GT_UITextures - .fallbackableProgressbar("auto_chisel", GT_UITextures.PROGRESSBAR_COMPRESS); - - @Override - protected BasicUIProperties getUIProperties() { - return super.getUIProperties().toBuilder() - .progressBarTexture(progressBarTexture) - .build(); - } - - @Override - protected SlotWidget createItemInputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { - return (SlotWidget) super.createItemInputSlot(index, backgrounds, pos) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_COMPRESSOR); - } - - @Override - protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos, BasicUIProperties uiProperties) { - return (SlotWidget) super.createSpecialSlot(backgrounds, pos, uiProperties) - .setGTTooltip(() -> mTooltipCache.getData("GTPP.machines.chisel_slot.tooltip")); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java deleted file mode 100644 index b1289958a9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ /dev/null @@ -1,672 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.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.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; - -public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { - - private int mCurrentDimension = 0; - public int mMode = 0; - public boolean mLocked = true; - - public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaWirelessCharger(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Can be locked to the owner by sneaking with a screwdriver", - "Can also be locked with a lock upgrade", "", "3 Modes, Long-Range, Local and Mixed.", - "Long-Range: Can supply 2A of power to a single player up to " + (GT_Values.V[this.mTier] * 4) + "m away.", - "Local: Can supply several Amps to each player within " + this.mTier * 20 + "m.", - "Mixed: Provides both 2A of long range and 1A per player locally.", - "Mixed mode is more conservative of power and as a result only", - "Gets half the distances each singular mode gets.", CORE.GT_Tooltip.get() }; - } - - public int getTier() { - return this.mTier; - } - - public int getMode() { - return this.mMode; - } - - public int getDimensionID() { - return this.mCurrentDimension; - } - - public Map getLocalMap() { - return this.mLocalChargingMap; - } - - public Map getLongRangeMap() { - return this.mWirelessChargingMap; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - if (aPlayer.isSneaking()) { - mLocked = !mLocked; - PlayerUtils.messagePlayer(aPlayer, mLocked ? "Locked to owner." : "Unlocked."); - return; - } - - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!this.getBaseMetaTileEntity() - .getWorld().playerEntities.isEmpty()) { - for (Object mTempPlayer : this.getBaseMetaTileEntity() - .getWorld().playerEntities) { - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - - if (this.mMode >= 2) { - this.mMode = 0; - } else { - this.mMode++; - } - if (this.mMode == 0) { - PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Charge Mode."); - } else if (this.mMode == 1) { - PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Charge Mode."); - } - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaWirelessCharger( - this.mName, - this.mTier, - this.mDescription, - this.mTextures, - this.mInventory.length); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * 128; - } - - @Override - public int getCapacity() { - return (int) (GT_Values.V[this.mTier] * 32); - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - if (this.mMode == 0) { - return 2; - } else if (this.mMode == 1) { - return this.mLocalChargingMap.size() * 8; - } else { - return ((this.mLocalChargingMap.size() * 4) + this.mWirelessChargingMap.size()); - } - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return 0; - } - - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyStored(); - } - - @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyCapacity(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - return new String[] { this.getLocalName() }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setBoolean("mLocked", this.mLocked); - aNBT.setInteger("mMode", this.mMode); - aNBT.setInteger("mCurrentDimension", this.mCurrentDimension); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mLocked = aNBT.getBoolean("mLocked"); - this.mMode = aNBT.getInteger("mMode"); - this.mCurrentDimension = aNBT.getInteger("mCurrentDimension"); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - } - - private Map mWirelessChargingMap = new HashMap<>(); - private Map mLocalChargingMap = new HashMap<>(); - - private boolean isValidPlayer(EntityPlayer aPlayer) { - BaseMetaTileEntity aTile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); - if (mLocked || (aTile != null && aTile.privateAccess())) { - if (aPlayer.getUniqueID() - .equals(getBaseMetaTileEntity().getOwnerUuid())) { - return true; - } else { - return false; - } - } - return true; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity() - .isServerSide()) { - - if (this.mCurrentDimension != aBaseMetaTileEntity.getWorld().provider.dimensionId) { - this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId; - } - - if (aTick % 20 == 0) { - boolean mHasBeenMapped = this.equals(ChargingHelper.getEntry(getTileEntityPosition())); - if (!mHasBeenMapped) { - mHasBeenMapped = ChargingHelper.addEntry(getTileEntityPosition(), this); - } - - if (mHasBeenMapped && !aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()) { - for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities) { - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - - if (this.mMode == 1 || this.mMode == 2) { - int tempRange = (this.mMode == 1 ? this.mTier * 20 : this.mTier * 10); - if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) - < tempRange) { - if (isValidPlayer(mTemp) - && !mLocalChargingMap.containsKey(mTemp.getDisplayName())) { - mLocalChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); - ChargingHelper.addValidPlayer(mTemp, this); - // PlayerUtils.messagePlayer(mTemp, "You have entered charging range. - // ["+tempRange+"m - Local]."); - } - } else { - if (mLocalChargingMap.containsKey(mTemp.getDisplayName())) { - if (mLocalChargingMap.remove(mTemp.getDisplayName()) != null) { - // PlayerUtils.messagePlayer(mTemp, "You have left charging range. - // ["+tempRange+"m - Local]."); - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - } - if (this.mMode == 0 || this.mMode == 2) { - int tempRange = (int) (this.mMode == 0 ? 4 * GT_Values.V[this.mTier] - : 2 * GT_Values.V[this.mTier]); - if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) - <= tempRange) { - if (!mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { - if (isValidPlayer(mTemp)) { - mWirelessChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); - ChargingHelper.addValidPlayer(mTemp, this); - PlayerUtils.messagePlayer( - mTemp, - "You have entered charging range. [" + tempRange + "m - Long-Range]."); - } - } - } else { - if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { - if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null) { - PlayerUtils.messagePlayer( - mTemp, - "You have left charging range. [" + tempRange + "m - Long Range]."); - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - } - /* - * if (this.mMode == 0 || this.mMode == 2){ int tempRange = (int) (this.mMode == 0 ? - * 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if - * (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < - * tempRange){ if (!mWirelessChargingMap.containsKey(mTemp)){ - * mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); - * PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); - * ChargingHelper.addValidPlayer(mTemp, this); } } else { if - * (mWirelessChargingMap.containsKey(mTemp)){ if (mWirelessChargingMap.remove(mTemp) != - * null){ PlayerUtils.messagePlayer(mTemp, - * "You have left charging range. ["+tempRange+"m]."); - * ChargingHelper.removeValidPlayer(mTemp, this); } } } } - */ - - } - } - } - } - } - } - - public BlockPos getTileEntityPosition() { - return new BlockPos( - this.getBaseMetaTileEntity() - .getXCoord(), - this.getBaseMetaTileEntity() - .getYCoord(), - this.getBaseMetaTileEntity() - .getZCoord(), - this.getBaseMetaTileEntity() - .getWorld()); - } - - public BlockPos getPositionOfEntity(Entity mEntity) { - if (mEntity == null) { - return null; - } - return EntityUtils.findBlockPosUnderEntity(mEntity); - } - - public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB) { - if (objectA == null || objectB == null) { - return 0f; - } - int[] objectArray1 = new int[] { objectA.xPos, objectA.yPos, objectA.zPos }; - int[] objectArray2 = new int[] { objectB.xPos, objectB.yPos, objectB.zPos }; - - final double distance = Math.sqrt( - (objectArray2[0] - objectArray1[0]) * (objectArray2[0] - objectArray1[0]) - + (objectArray2[1] - objectArray1[1]) * (objectArray2[1] - objectArray1[1]) - + (objectArray2[2] - objectArray1[2]) * (objectArray2[2] - objectArray1[2])); - return distance; - } - - @Override - public void onRemoval() { - - ChargingHelper.removeEntry(getTileEntityPosition(), this); - - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!this.getBaseMetaTileEntity() - .getWorld().playerEntities.isEmpty()) { - for (Object mTempPlayer : this.getBaseMetaTileEntity() - .getWorld().playerEntities) { - if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { - EntityPlayer mTemp = (EntityPlayer) mTempPlayer; - ChargingHelper.removeValidPlayer(mTemp, this); - } - } - } - - super.onRemoval(); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { - - int tempRange; - - if (this.mMode == 0 || this.mMode == 2) { - tempRange = (int) (this.mMode == 0 ? 4 * GT_Values.V[this.mTier] : 2 * GT_Values.V[this.mTier]); - } else { - tempRange = this.mMode == 1 ? this.mTier * 20 : this.mTier * 10; - } - - if (this.mMode == 2) { - PlayerUtils - .messagePlayer(aPlayer, "Mixed Mode | Local: " + this.mTier * 10 + "m | Long: " + tempRange + "m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLocalMap() - .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "Local: " + name); - } - for (String name : this.getLongRangeMap() - .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "Long: " + name); - } - } else if (this.mMode == 1) { - PlayerUtils.messagePlayer(aPlayer, "Local Mode: " + this.mTier * 20 + "m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLocalMap() - .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "" + name); - } - - } else { - PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: " + tempRange + "m"); - PlayerUtils.messagePlayer(aPlayer, "Players with access:"); - for (String name : this.getLongRangeMap() - .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "" + name); - } - } - - return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - } - - @Override - public void onServerStart() { - mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - super.onServerStart(); - } - - @Override - public void onExplosion() { - ChargingHelper.removeEntry(getTileEntityPosition(), this); - super.onExplosion(); - } - - @Override - public void doExplosion(long aExplosionPower) { - ChargingHelper.removeEntry(getTileEntityPosition(), this); - super.doExplosion(aExplosionPower); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java new file mode 100644 index 0000000000..3a85e0aae3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java @@ -0,0 +1,887 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GTValues.V; + +import java.util.Collections; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +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 gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.MetaGeneratedTool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicMachine; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gregtech.common.items.IDMetaTool01; +import gregtech.common.items.MetaGeneratedTool01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAtmosphericReconditioner extends MTEBasicMachine { + + public int mPollutionReduction = 0; + protected int mBaseEff = 2500; + protected int mOptimalAirFlow = 0; + protected boolean mHasPollution = false; + protected int SLOT_ROTOR = 5; + protected int SLOT_FILTER = 6; + protected static boolean mPollutionEnabled = true; + + protected boolean mSaveRotor = false; + + public MTEAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 2, + "Making sure you don't live in Gwalior - Uses 2A", + 3, + 0, + new ITexture[] { new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + public MTEAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 2, aDescription, aTextures, 2, 0); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAtmosphericReconditioner(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public String[] getDescription() { + + boolean highTier = this.mTier >= 7; + + String[] A = ArrayUtils.addAll( + this.mDescriptionArray, + highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", + highTier ? "If these chunks are not loaded, they will be ignored" : "", + "Requires a turbine rotor and an Air Filter [T1/T2] to run.", + "The turbine rotor must be manually inserted/replaced", + "Can be configured with a soldering iron to change modes", + "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", + "High Efficiency: Removes full pollution, Turbine takes 100% dmg", + "Turbine Rotor will not break in LE mode", + "Insert an equal tier Conveyor Module to enable automation"); + if (!mPollutionEnabled) { + String[] B = new String[] { "===============================================", + "Pollution is disabled, scrubbers will now have a bonus use", + "They are now able to remove ALL lingering pollution as GT ignores it", "and it will linger forever!", + "===============================================", }; + A = ArrayUtils.addAll(A, B); + } + return A; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow"); + this.mSaveRotor = aNBT.getBoolean("mSaveRotor"); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[mTier] * 256; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + + // Get Current Pollution Amount. + int mCurrentPollution = getCurrentChunkPollution(); + boolean isIdle = true; + + // Get Inventory Item + ItemStack stackRotor = this.mInventory[SLOT_ROTOR]; + ItemStack stackFilter = this.mInventory[SLOT_FILTER]; + + // Power Drain + long drainEU = maxEUInput() * maxAmperesIn(); + if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU) { + if (aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)) { + isIdle = false; + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU / 4) { + if (aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU / 4), false)) { + isIdle = false; + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + + // Only try once/sec. + if (!isIdle && aTick % 20L == 0L) { + + for (int i = 0; i < this.mInventory.length; i++) { + ItemStack aSlotContent = this.mInventory[i]; + if (aSlotContent != null) { + Logger.INFO("Found " + aSlotContent.getDisplayName() + " in slot " + i); + } + } + + for (int i = 0; i < this.mInventory.length; i++) { + if (hasRotor(this.mInventory[i])) { + Logger.INFO("Found Rotor in slot " + i); + break; + } + } + for (int i = 0; i < this.mInventory.length; i++) { + if (hasAirFilter(this.mInventory[i])) { + Logger.INFO("Found Filter in slot " + i); + break; + } + } + + // Check if machine can work. + if ((aBaseMetaTileEntity.isAllowedToWork())) { + Logger.INFO("Can work."); + + // Enable machine animation/graphic + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution) { + if (!this.getBaseMetaTileEntity() + .isActive()) { + Logger.INFO("Set Active."); + aBaseMetaTileEntity.setActive(true); + } + } else if (!this.mHasPollution || mCurrentPollution <= 0 + || stackRotor == null + || stackFilter == null + || !hasRotor(stackRotor) + || !hasAirFilter(stackFilter)) { + if (!this.getBaseMetaTileEntity() + .isActive()) { + Logger.INFO("Set Inactive."); + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } + + // If Active. + if (aBaseMetaTileEntity.isActive()) { + Logger.INFO("Doing something."); + + // Do nothing if there is no pollution. + if (this.mHasPollution && mCurrentPollution > 0) { + Logger + .INFO("Has Pollution? " + mHasPollution + ", Current Pollution: " + mCurrentPollution); + + // Only check every 30s. + if (!isIdle && aTick % (20L * 30) == 0L) { + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + // Clear out pollution if it's disabled, because I am a nice gal. + if (!PollutionUtils.isPollutionEnabled()) { + PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); + } + } + + // Use a Turbine + if (hasRotor(stackRotor) && hasAirFilter(stackFilter)) { + Logger.INFO("Found Turbine."); + + mBaseEff = getBaseEfficiency(stackRotor); + mOptimalAirFlow = getOptimalAirFlow(stackRotor); + + // Make sure we have a valid Turbine and Eff/Airflow + if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0) { + // Utils.LOG_WARNING("Pollution Cleaner [5]"); + + // Log Debug information. + Logger.INFO("mBaseEff[1]:" + mBaseEff); + Logger.INFO("mOptimalAirFlow[1]:" + mOptimalAirFlow); + + // Calculate The Voltage we are running + long tVoltage = drainEU; + byte tTier = (byte) Math.max(1, GTUtility.getTier(tVoltage)); + + // Check Sides for Air, + // More air means more pollution processing. + int mAirSides = getFreeSpaces(); + + int reduction = 0; + + // If no sides are free, how will you process the atmosphere? + if (mAirSides > 0) { + reduction += (((Math.max((tTier - 2), 1) * 2) * 50) * mAirSides); // Was + // originally + // *100 + Logger.INFO("mPollutionReduction[1]:" + reduction); + + // I stole this code + reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) + * mAirSides + * Math.max((tTier - 2), 1); + Logger.INFO("reduction[2]:" + reduction); + reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); + Logger.INFO("reduction[3]:" + reduction); + + mPollutionReduction = reduction; + + // Set a temp to remove variable to aleviate duplicate code. + int toRemove = 0; + + Logger.INFO("mCurrentPollution[4]:" + mCurrentPollution); + Logger.INFO("mCurrentPollution[5]:" + reduction); + if (reduction <= mCurrentPollution) { + // Clean some Air. + toRemove = reduction; + } else { + // Makes sure we don't get negative pollution. + toRemove = mCurrentPollution; + } + + toRemove = toRemove / 2; + Logger.INFO("mCurrentPollution[6]:" + toRemove); + + // We are good to clean + if (toRemove > 0) { + if (damageTurbineRotor() && damageAirFilter()) { + Logger.INFO("Removing " + toRemove + " pollution"); + removePollution(mSaveRotor ? (toRemove / 2) : toRemove); + Logger.INFO("mNewPollution[4]:" + getCurrentChunkPollution()); + } else { + Logger.INFO("Could not damage turbine rotor or Air Filter."); + aBaseMetaTileEntity.setActive(false); + } + } // End of pollution removal block. + } // End of valid air sides block. + } // End of valid toolstats block. + } // End of correct inventory item block. + else { + // Utils.LOG_WARNING("Wrong Tool metaitem Found."); + } + } + } else if (!aBaseMetaTileEntity.isActive()) { + return; + } + } // End of can work block. + else { // Disable Machine. + // aBaseMetaTileEntity.setActive(false); + } + } // End of 1/sec action block. + else { + + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) + && this.mHasPollution + && !isIdle + && aBaseMetaTileEntity.isAllowedToWork()) { + aBaseMetaTileEntity.setActive(true); + } else if (isIdle || !this.mHasPollution + || mCurrentPollution <= 0 + || stackRotor == null + || stackFilter == null + || !hasRotor(stackRotor) + || !hasAirFilter(stackFilter)) { + aBaseMetaTileEntity.setActive(false); + } + } + if (this.getBaseMetaTileEntity() + .isActive()) { + if (MathUtils.randInt(0, 5) <= 2) { + this.sendSound((byte) -120); + } + } + } // End of is serverside block. + } + + public int getCurrentChunkPollution() { + int mCurrentChunkPollution = 0; + if (this.mTier < 7) { + mCurrentChunkPollution = PollutionUtils.getPollution(getBaseMetaTileEntity()); + } else { + AutoMap aSurrounding = new AutoMap<>(); + World aWorld = this.getBaseMetaTileEntity() + .getWorld(); + int xPos = this.getBaseMetaTileEntity() + .getXCoord(); + int zPos = this.getBaseMetaTileEntity() + .getZCoord(); + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + for (Chunk r : aSurrounding) { + mCurrentChunkPollution += getPollutionInChunk(r); + } + } + if (mCurrentChunkPollution > 0) { + mHasPollution = true; + } else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public int getPollutionInChunk(Chunk aChunk) { + int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); + if (mCurrentChunkPollution > 0) { + mHasPollution = true; + } else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public boolean hasRotor(ItemStack rotorStack) { + if (rotorStack != null) { + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + // Logger.INFO("Found Basic Turbine Rotor."); + return true; + } else if (rotorStack.getItem() instanceof MetaGeneratedTool && rotorStack.getItemDamage() >= 170 + && rotorStack.getItemDamage() <= 179) { + // Logger.INFO("Found Turbine Rotor."); + return true; + } else { + // Logger.INFO("Found: "+rotorStack.getDisplayName()+":"+rotorStack.getItemDamage()); + } + } + // Logger.INFO("Found No Turbine Rotor."); + return false; + } + + public boolean damageTurbineRotor() { + try { + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack == null) { + return false; + } else if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); + // Remove broken Filter + if (rotorStack.getItemDamage() == 0 && currentUse >= 2000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T1"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (rotorStack.getItemDamage() == 1 && currentUse >= 4000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T2"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (rotorStack.getItemDamage() == 2 && currentUse >= 6000 - 10) { + Logger.INFO("Depleting ItemBasicScrubberTurbine T3"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else { + // Do Damage + Logger.INFO("Damaging ItemBasicScrubberTurbine"); + ItemBasicScrubberTurbine.setFilterDamage(rotorStack, currentUse + 10); + Logger.INFO("Rotor Damage: " + currentUse); + return true; + } + } else if (rotorStack.getItem() instanceof MetaGeneratedTool01) { + Materials t1 = MetaGeneratedTool.getPrimaryMaterial(rotorStack); + Materials t2 = MetaGeneratedTool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL) { + Logger.INFO("Found creative rotor."); + creativeRotor = true; + } + } else { + Logger.INFO("Bad item in rotor slot."); + return false; + } + + if (mInventory[SLOT_ROTOR].getItem() instanceof MetaGeneratedTool01 + && ((MetaGeneratedTool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]) + .getSpeedMultiplier() > 0 + && MetaGeneratedTool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed > 0) { + + long damageValue = (long) Math + .floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); + double fDam = Math + .floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); + damageValue -= fDam; + + // Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); + /* + * Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); Materials + * M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); + * Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]"); + */ + + // Damage Rotor + // int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); + long rotorDamage = creativeRotor ? 0 + : MetaGeneratedTool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurabilityMax = creativeRotor ? Integer.MAX_VALUE + : MetaGeneratedTool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurability = (rotorDurabilityMax - rotorDamage); + Logger.INFO( + "Rotor Damage: " + rotorDamage + + " | Max Durability: " + + rotorDurabilityMax + + " | " + + " Remaining Durability: " + + rotorDurability); + if (rotorDurability >= damageValue) { + + if (!mSaveRotor) { + Logger.INFO("Damaging Rotor."); + + if (!creativeRotor) GTModHandler + .damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); + + long tempDur = MetaGeneratedTool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax) { + return true; + } else { + rotorDurability = 0; + } + } else { + Logger.INFO("Damaging Rotor."); + if (rotorDurability > 1000) { + if (!creativeRotor) GTModHandler + .damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue / 2, 0, null); + long tempDur = MetaGeneratedTool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax) { + return true; + } else { + rotorDurability = 0; + } + } + } + } + + if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { + Logger.INFO("Destroying Rotor."); + this.mInventory[this.SLOT_ROTOR] = null; + return false; + } else if (rotorDurability <= 0 && mSaveRotor) { + Logger.INFO("Saving Rotor."); + return false; + } + + } else { + Logger.INFO("Bad Rotor."); + return false; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } + + public int getFreeSpaces() { + int mAir = 0; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (aBaseMetaTileEntity.getAirOffset(1, 0, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(-1, 0, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 0, 1)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 0, -1)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, 1, 0)) { + mAir++; + } + if (aBaseMetaTileEntity.getAirOffset(0, -1, 0)) { + mAir++; + } + return mAir; + } + + public boolean removePollution(int toRemove) { + + if (this == null || this.getBaseMetaTileEntity() == null + || this.getBaseMetaTileEntity() + .getWorld() == null) { + return false; + } + + if (this.mTier < 7) { + int startPollution = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: " + startPollution); + PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); + int after = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: " + after); + return (after < startPollution); + } else { + int chunksWithRemoval = 0; + int totalRemoved = 0; + AutoMap aSurrounding = new AutoMap<>(); + Chunk aThisChunk = this.getBaseMetaTileEntity() + .getWorld() + .getChunkFromBlockCoords( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + int mainChunkX = aThisChunk.xPosition; + int mainChunkZ = aThisChunk.zPosition; + + World aWorld = this.getBaseMetaTileEntity() + .getWorld(); + int xPos = this.getBaseMetaTileEntity() + .getXCoord(); + int zPos = this.getBaseMetaTileEntity() + .getZCoord(); + + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos - 32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos - 32, zPos + 32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos - 32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos + 32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos - 32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos + 32, zPos + 32); + + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + + for (Chunk r : aSurrounding) { + if (!r.isChunkLoaded) { + continue; + } + + int startPollution = getPollutionInChunk(r); + if (startPollution == 0) { + continue; + } + + Logger.INFO( + "Trying to remove pollution from chunk " + r.xPosition + + ", " + + r.zPosition + + " | " + + startPollution); + int after = 0; + boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); + + int removal = Math.max(0, !isMainChunk ? (toRemove / 4) : toRemove); + if (removePollution(r, removal)) { + chunksWithRemoval++; + after = getPollutionInChunk(r); + } else { + after = 0; + } + if (startPollution - after > 0) { + totalRemoved += (startPollution - after); + } + Logger.INFO( + "Removed " + (startPollution - after) + + " pollution from chunk " + + r.xPosition + + ", " + + r.zPosition + + " | " + + after); + } + return totalRemoved > 0 && chunksWithRemoval > 0; + } + } + + public boolean removePollution(Chunk aChunk, int toRemove) { + int before = getCurrentChunkPollution(); + PollutionUtils.removePollution(aChunk, toRemove); + int after = getCurrentChunkPollution(); + return (after < before); + } + + public boolean hasAirFilter(ItemStack filter) { + if (filter == null) { + return false; + } + return filter.getItem() instanceof ItemAirFilter; + } + + public boolean damageAirFilter() { + ItemStack filter = this.mInventory[this.SLOT_FILTER]; + if (filter == null) { + return false; + } + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack != null) { + if (rotorStack.getItem() instanceof MetaGeneratedTool01) { + Materials t1 = MetaGeneratedTool.getPrimaryMaterial(rotorStack); + Materials t2 = MetaGeneratedTool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL) { + creativeRotor = true; + } + } + } + + if (creativeRotor) { + return true; + } + + if (filter.getItem() instanceof ItemAirFilter) { + + long currentUse = ItemAirFilter.getFilterDamage(filter); + + // Remove broken Filter + if (filter.getItemDamage() == 0 && currentUse >= 50 - 1) { + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else if (filter.getItemDamage() == 1 && currentUse >= 2500 - 1) { + this.mInventory[this.SLOT_FILTER] = null; + return false; + } else { + // Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse + 1); + Logger.INFO("Filter Damage: " + currentUse); + return true; + } + } + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { + if (aIndex == SLOT_FILTER) { + if (aStack.getItem() instanceof ItemAirFilter) { + Logger.INFO("Inserting Air Filter into " + aIndex); + return true; + } + } + if (aIndex == SLOT_ROTOR) { + if (this.mInventory[7] != null) { + Logger.INFO("Found conveyor, can automate turbines. Inserting into " + aIndex); + if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (aStack.getItem() instanceof MetaGeneratedTool && aStack.getItemDamage() >= 170 + && aStack.getItemDamage() <= 179) { + return true; + } + } + } + return false; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + if (aIndex == -120) { + GTUtility.doSoundAtClient(SoundResource.IC2_TOOLS_BATTERY_USE, MathUtils.randInt(5, 50), 0.05F, aX, aY, aZ); + } else { + super.doSound((byte) 0, aX, aY, aZ); + } + } + + @Override + public String[] getInfoData() { + AutoMap aTooltipSuper = new AutoMap<>(); + for (String s : super.getInfoData()) { + aTooltipSuper.put(s); + } + int mAirSides = getFreeSpaces(); + int reduction = 0; + + try { + long tVoltage = maxEUInput(); + byte tTier = (byte) Math.max(1, GTUtility.getTier(tVoltage)); + reduction += (((Math.max((tTier - 2), 1) * 2) * 50) * mAirSides); + reduction = (MathUtils.safeInt((long) reduction * this.mBaseEff) / 100000) * mAirSides + * Math.max((tTier - 2), 1); + reduction = MathUtils.safeInt(((long) reduction / 100) * this.mOptimalAirFlow); + + aTooltipSuper.put("Maximum pollution removed per second: " + reduction); + } catch (Throwable t) { + aTooltipSuper.put("Maximum pollution removed per second: " + mPollutionReduction); + } + aTooltipSuper.put("Air Sides: " + mAirSides); + + String[] mBuiltOutput = new String[aTooltipSuper.size()]; + int aIndex = 0; + for (String i : aTooltipSuper) { + mBuiltOutput[aIndex++] = i; + } + + return mBuiltOutput; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aCoverID) { + if (side.offsetY != 0) { + return false; + } + return super.allowCoverOnSide(side, aCoverID); + } + + @Override + public ITexture[] getTopFacingInactive(byte aColor) { + return super.getTopFacingInactive(aColor); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + super.setItemNBT(aNBT); + } + + private static ItemStack[] sGregTurbines; + + public static ItemStack getTieredTurbine(int aTier) { + if (sGregTurbines == null) { + sGregTurbines = new ItemStack[3]; + sGregTurbines[0] = MetaGeneratedTool.sInstances.get("gt.metatool.01") + .getToolWithStats(IDMetaTool01.TURBINE_SMALL.ID, 1, Materials.Iron, Materials.Iron, null); + sGregTurbines[1] = MetaGeneratedTool.sInstances.get("gt.metatool.01") + .getToolWithStats(IDMetaTool01.TURBINE_SMALL.ID, 1, Materials.Bronze, Materials.Bronze, null); + sGregTurbines[2] = MetaGeneratedTool.sInstances.get("gt.metatool.01") + .getToolWithStats(IDMetaTool01.TURBINE_SMALL.ID, 1, Materials.Steel, Materials.Steel, null); + } else { + return sGregTurbines[aTier]; + } + + return null; + } + + public int getBaseEfficiency(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getBaseEfficiency(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) ((50.0F + (10.0F * ((MetaGeneratedTool) aStackRotor.getItem()).getToolCombatDamage(aStackRotor))) + * 100); + } + + public int getOptimalAirFlow(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getOptimalAirFlow(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) Math.max( + Float.MIN_NORMAL, + ((MetaGeneratedTool) aStackRotor.getItem()).getToolStats(aStackRotor) + .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(aStackRotor).mToolSpeed * 50); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget(new SlotWidget(inventoryHandler, SLOT_ROTOR).setFilter(stack -> { + if (stack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + return stack.getItem() instanceof MetaGeneratedTool && stack.getItemDamage() >= 170 + && stack.getItemDamage() <= 179; + }) + .setBackground(getGUITextureSet().getItemSlot(), GTPPUITextures.OVERLAY_SLOT_TURBINE) + .setPos(52, 24)) + .widget( + new SlotWidget(inventoryHandler, SLOT_FILTER) + .setFilter(stack -> stack.getItem() instanceof ItemAirFilter) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_RECYCLE) + .setPos(106, 24)) + .widget( + new SlotWidget(inventoryHandler, 7) + .setFilter(stack -> GTUtility.areStacksEqual(stack, CI.getConveyor(mTier, 1), true)) + .setPos(124, 62)); + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_INFORMATION) + .dynamicTooltip(() -> Collections.singletonList("Reduction: " + mPollutionReduction + "/s")) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer(() -> mPollutionReduction, val -> mPollutionReduction = val), + builder, + (widget, val) -> widget.notifyTooltipChange()) + .setPos(163, 5) + .setSize(7, 18)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java new file mode 100644 index 0000000000..6cdc97130b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java @@ -0,0 +1,184 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicMachine; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.BasicUIProperties; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import team.chisel.carving.Carving; + +public class MTEAutoChisel extends MTEBasicMachine { + + private ItemStack mInputCache; + private ItemStack mOutputCache; + + public MTEAutoChisel(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Chisels things, Gregtech style", + 1, + 1, + new ITexture[] { new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), + new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); + } + + public MTEAutoChisel(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAutoChisel(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + this.mDescriptionArray, + "What you want to chisel goes in slot 1", + "What you want to get goes in the special slot (bottom right)", + "If special slot is empty, first chisel result is used"); + } + + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { + if (mInputCache != null && mOutputCache != null) { + if (GTUtility.areStacksEqual(aStack, mInputCache) && GTUtility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } + } + // clear cache if it was invalid + if (aClearOnFailure) { + mInputCache = null; + mOutputCache = null; + } + return false; + } + + private void cacheItem(ItemStack mInputItem, ItemStack mOutputItem) { + mOutputCache = mOutputItem.copy(); + mInputCache = mInputItem.copy(); + } + + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return hasValidCache(aStack, this.getSpecialSlot(), false) ? true + : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && hasChiselResults(aStack); + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; + } + + private static List getItemsForChiseling(ItemStack aStack) { + return Carving.chisel.getItemsForChiseling(aStack); + } + + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput = null; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + + @Override + public int checkRecipe() { + ItemStack tOutput = null; + ItemStack aInput = getInputAt(0); + ItemStack aTarget = getSpecialSlot(); + boolean tIsCached = hasValidCache(aInput, aTarget, true); + if (aInput != null && hasChiselResults(aInput) && aInput.stackSize > 0) { + tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, aTarget); + if (tOutput != null) { + tOutput = tOutput.copy(); + tOutput.stackSize = 1; + // We can chisel this + if (canOutput(tOutput)) { + getInputAt(0).stackSize -= 1; + calculateOverclockedNess(16, 20); + // In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tIsCached) { + cacheItem(ItemUtils.getSimpleStack(aInput, 1), ItemUtils.getSimpleStack(tOutput, 1)); + } + this.mOutputItems[0] = tOutput.copy(); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } else { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + } + } + return DID_NOT_FIND_RECIPE; + } + + private static final FallbackableUITexture progressBarTexture = GTUITextures + .fallbackableProgressbar("auto_chisel", GTUITextures.PROGRESSBAR_COMPRESS); + + @Override + protected BasicUIProperties getUIProperties() { + return super.getUIProperties().toBuilder() + .progressBarTexture(progressBarTexture) + .build(); + } + + @Override + protected SlotWidget createItemInputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) super.createItemInputSlot(index, backgrounds, pos) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_COMPRESSOR); + } + + @Override + protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos, BasicUIProperties uiProperties) { + return (SlotWidget) super.createSpecialSlot(backgrounds, pos, uiProperties) + .setGTTooltip(() -> mTooltipCache.getData("GTPP.machines.chisel_slot.tooltip")); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java new file mode 100644 index 0000000000..07884ed745 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java @@ -0,0 +1,706 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.gtnhlib.util.map.ItemStackMap; +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 com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicTank; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import ic2.api.crops.CropCard; +import ic2.api.crops.ICropTile; +import ic2.core.item.DamageHandler; + +public class MTECropHarvestor extends MTEBasicTank { + + private static final int SLOT_WEEDEX_1 = 1; + private static final int SLOT_WEEDEX_2 = 2; + private static final int SLOT_FERT_1 = 3; + private static final int SLOT_FERT_4 = 6; + private static final int SLOT_OUTPUT_START = 7; + + public boolean mModeAlternative = false; + public boolean mHarvestEnabled = true; + + public MTECropHarvestor(final int aID, final int aTier, final String aDescription) { + super( + aID, + "basicmachine.cropharvester.0" + aTier, + "Crop Manager (" + GTValues.VN[aTier] + ")", + aTier, + 21, + aDescription); + } + + public MTECropHarvestor(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 21, aDescription, aTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public long maxAmperesIn() { + return 8; + } + + @Override + public long getMinimumStoredEU() { + return GTValues.V[this.mTier]; + } + + @Override + public long maxEUStore() { + return GTValues.V[this.mTier] * (this.mTier * GTValues.V[this.mTier]); + } + + @Override + public long maxEUInput() { + return GTValues.V[this.mTier]; + } + + @Override + public int getCapacity() { + return 32000 * this.mTier; + } + + @Override + public int getTankPressure() { + return -100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTECropHarvestor(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public int getSizeInventory() { + return 21; + } + + private static int getRange(int aTier) { + return switch (aTier) { + case 1 -> 1; + case 2 -> 5; + case 3 -> 9; + case 4 -> 13; + case 5 -> 17; + case 6 -> 21; + case 7 -> 25; + case 8 -> 29; + case 9 -> 33; + default -> 0; + }; + } + + private HashSet mCropCache = new HashSet<>(); + private boolean mInvalidCache = false; + + public boolean doesInventoryHaveSpace() { + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory(); i++) { + if (this.mInventory[i] == null || this.mInventory[i].stackSize < 64) { + return true; + } + } + return false; + } + + public long powerUsage() { + return this.maxEUInput() / 8; + } + + public long powerUsageSecondary() { + return this.maxEUInput() / 32; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (!getBaseMetaTileEntity().isServerSide() || !getBaseMetaTileEntity().isAllowedToWork() + || (!getBaseMetaTileEntity().hasWorkJustBeenEnabled() && aTick % 100 != 0)) return; + + if (this.getBaseMetaTileEntity() + .getUniversalEnergyStored() < getMinimumStoredEU()) return; + + int aTileX = this.getBaseMetaTileEntity() + .getXCoord(); + int aTileY = this.getBaseMetaTileEntity() + .getXCoord(); + int aTileZ = this.getBaseMetaTileEntity() + .getXCoord(); + + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius - 1) / 2; + Map aAllDrops = new ItemStackMap<>(true); + + if (this.mCropCache.isEmpty() || aTick % 1200 == 0 || this.mInvalidCache) { + if (!this.mCropCache.isEmpty()) { + this.mCropCache.clear(); + } + // Logger.INFO("Looking for crops."); + for (int y = -2; y <= 2; y++) { + for (int x = (-aSide); x <= aSide; x++) { + for (int z = (-aSide); z <= aSide; z++) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); + if (tTileEntity != null && tTileEntity instanceof ICropTile tCrop) { + this.mCropCache.add(tCrop); + } + } + } + } + } + + // Process Cache + if (!doesInventoryHaveSpace()) return; + + for (ICropTile tCrop : this.mCropCache) { + if (tCrop == null) { + this.mInvalidCache = true; + break; + } + CropCard aCrop = tCrop.getCrop(); + if (aCrop == null) continue; + + if (this.mModeAlternative) processSecondaryFunctions(tCrop); + if (!this.mHarvestEnabled) continue; + + if (aCrop.canBeHarvested(tCrop) && tCrop.getSize() == aCrop.getOptimalHavestSize(tCrop)) { + if (!getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsage(), true)) continue; + ItemStack[] aHarvest = tCrop.harvest_automated(true); + if (aHarvest == null) continue; + + for (ItemStack aStack : aHarvest) { + if (!ItemUtils.checkForInvalidItems(aStack)) continue; + if (this.mTier * 5 > MathUtils.randInt(1, 100)) { + aStack.stackSize += Math.floor(tCrop.getGain() / 10); + Logger.INFO("Bonus output given for " + aCrop.displayName()); + } + Logger.INFO("Harvested " + aCrop.displayName()); + aAllDrops.merge(aStack, aStack.stackSize, Integer::sum); + } + } + } + + if (aAllDrops.isEmpty()) return; + + Logger.INFO("Handling " + aAllDrops.size() + " Harvests"); + + for (var dropEntry : aAllDrops.entrySet()) { + ItemStack dropItem = dropEntry.getKey(); + int dropAmount = dropEntry.getValue(); + + // how this can happen, idk + if (dropItem == null) continue; + + for (int i = SLOT_OUTPUT_START; i < this.getSizeInventory() && dropAmount > 0; i++) { + ItemStack invStack = mInventory[i]; + + // If the slot is empty, create a new stack for the drop item, else check if it is the same as the drop + // and merge if possible + if (invStack == null || GTUtility.isStackInvalid(invStack) || invStack.stackSize == 0) { + int stackSize = Math.min(dropAmount, dropItem.getMaxStackSize()); + getBaseMetaTileEntity().setInventorySlotContents(i, GTUtility.copyAmount(stackSize, dropItem)); + dropAmount -= stackSize; + } else if (GTUtility.areStacksEqual(invStack, dropItem)) { + int space = Math.min(invStack.getMaxStackSize(), getInventoryStackLimit()) - invStack.stackSize; + if (dropAmount <= space) { + // if the drop amount fits + getBaseMetaTileEntity().addStackToSlot(i, invStack, dropAmount); + dropAmount = 0; + } else { + // fill the slot + getBaseMetaTileEntity().addStackToSlot(i, invStack, space); + dropAmount -= space; + } + } + } + } + } + + public boolean hasFertilizer() { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeFertilizer(boolean aSimulate) { + if (hasFertilizer()) { + for (int i = SLOT_FERT_1; i <= SLOT_FERT_4; i++) { + if (this.mInventory[i] != null) { + consume(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public boolean hasWeedEX() { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + return true; + } + } + return false; + } + + public boolean consumeWeedEX(boolean aSimulate) { + if (hasWeedEX()) { + for (int i = SLOT_WEEDEX_1; i <= SLOT_WEEDEX_2; i++) { + if (this.mInventory[i] != null) { + damage(i, 1, aSimulate); + return true; + } + } + } + return false; + } + + public void processSecondaryFunctions(ICropTile aCrop) { + if (!this.mModeAlternative) { + return; + } + if (hasFertilizer() && consumeFertilizer(true) + && this.getBaseMetaTileEntity() + .getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyFertilizer(aCrop)) { + if (consumeFertilizer(false)) { + // Logger.INFO("Consumed Fert."); + } + } + if (this.getFluidAmount() > 0 && this.getBaseMetaTileEntity() + .getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyHydration(aCrop)) { + // Logger.INFO("Consumed Water."); + } + if (hasWeedEX() && consumeWeedEX(true) + && this.getBaseMetaTileEntity() + .getUniversalEnergyStored() >= getMinimumStoredEU() + && getBaseMetaTileEntity().decreaseStoredEnergyUnits(powerUsageSecondary(), true) + && applyWeedEx(aCrop)) { + if (consumeWeedEX(false)) { + // Logger.INFO("Consumed Weed-EX."); + } + } + } + + public boolean applyWeedEx(ICropTile aCrop) { + if (aCrop.getWeedExStorage() < 150) { + aCrop.setWeedExStorage(aCrop.getWeedExStorage() + 50); + boolean triggerDecline; + triggerDecline = aCrop.getWorld().rand.nextInt(3) == 0; + if (aCrop.getCrop() != null && aCrop.getCrop() + .isWeed(aCrop) && aCrop.getWeedExStorage() >= 75 && triggerDecline) { + switch (aCrop.getWorld().rand.nextInt(5)) { + case 0: + if (aCrop.getGrowth() > 0) { + aCrop.setGrowth((byte) (aCrop.getGrowth() - 1)); + } + case 1: + if (aCrop.getGain() > 0) { + aCrop.setGain((byte) (aCrop.getGain() - 1)); + } + default: + if (aCrop.getResistance() > 0) { + aCrop.setResistance((byte) (aCrop.getResistance() - 1)); + } + } + } + return true; + } else { + return false; + } + } + + public boolean applyFertilizer(ICropTile aCrop) { + if (aCrop.getNutrientStorage() >= 100) { + return false; + } else { + // Logger.INFO("Current Nutrient: "+aCrop.getNutrientStorage()+" for "+aCrop.getCrop().displayName()); + aCrop.setNutrientStorage(aCrop.getNutrientStorage() + 100); + return true; + } + } + + public boolean applyHydration(ICropTile aCrop) { + if (aCrop.getHydrationStorage() >= 200 || this.getFluidAmount() == 0) { + // Logger.INFO("Hydration Max"); + return false; + } else { + int apply = 200 - aCrop.getHydrationStorage(); + if (this.getFluidAmount() >= 0) { + int drain = 0; + if (this.getFluidAmount() >= apply) { + drain = apply; + } else { + drain = this.getFluidAmount(); + } + this.mFluid.amount -= drain; + if (this.mFluid.amount <= 0) { + this.mFluid = null; + } + // Logger.INFO("Did Hydrate"); + aCrop.setHydrationStorage(aCrop.getHydrationStorage() + drain); + return true; + } else { + // Logger.INFO("No water?"); + return false; + } + } + } + + public boolean consume(int aSlot, int amount, boolean simulate) { + ItemStack stack = this.mInventory[aSlot]; + if (stack != null && stack.stackSize >= amount) { + int currentAmount = Math.min(amount, stack.stackSize); + amount -= currentAmount; + if (!simulate) { + if (stack.stackSize == currentAmount) { + this.mInventory[aSlot] = null; + } else { + stack.stackSize -= currentAmount; + } + } else { + return amount >= 0; + } + return true; + } + return false; + } + + public ItemStack damage(int aSlot, int amount, boolean simulate) { + ItemStack ret = null; + int damageApplied = 0; + ItemStack stack = this.mInventory[aSlot]; + Item item = stack.getItem(); + if (stack != null && item.isDamageable() + && (ret == null || stack.getItem() == ret.getItem() && ItemStack.areItemStackTagsEqual(stack, ret))) { + if (simulate) { + stack = stack.copy(); + } + int maxDamage = DamageHandler.getMaxDamage(stack); + while (amount > 0 && stack.stackSize > 0) { + int currentAmount = Math.min(amount, maxDamage - DamageHandler.getDamage(stack)); + DamageHandler.damage(stack, currentAmount, null); + damageApplied += currentAmount; + amount -= currentAmount; + if (DamageHandler.getDamage(stack) >= maxDamage) { + --stack.stackSize; + DamageHandler.setDamage(stack, 0); + } + + if (ret == null) { + ret = stack.copy(); + } + } + if (stack.stackSize == 0 && !simulate) { + this.mInventory[aSlot] = null; + } + } + + if (ret != null) { + int i = DamageHandler.getMaxDamage(ret); + ret.stackSize = damageApplied / i; + DamageHandler.setDamage(ret, damageApplied % i); + } + return ret; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return aStack != null && aIndex >= SLOT_OUTPUT_START && aIndex < this.getSizeInventory(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (aStack != null) { + if (aStack.getItem() + .getUnlocalizedName() + .equals("ic2.itemFertilizer")) { + return aIndex >= SLOT_FERT_1 && aIndex <= SLOT_FERT_4; + } else if (aStack.getItem() + .getUnlocalizedName() + .equals("ic2.itemWeedEx")) { + return aIndex >= SLOT_WEEDEX_1 && aIndex <= SLOT_WEEDEX_2; + } + } + return false; + } + + @Override + public String[] getDescription() { + int aRadius = 10 + getRange(this.mTier); + int aSide = (aRadius - 1) / 2; + return ArrayUtils.addAll( + this.mDescriptionArray, + "Secondary mode can Hydrate/Fertilize/Weed-EX", + "Consumes " + powerUsage() + "eu per harvest", + "Consumes " + powerUsageSecondary() + "eu per secondary operation", + "Can harvest 2 block levels above and below itself", + "Radius: " + aSide + " blocks each side (" + aRadius + "x3x" + aRadius + ")", + "Has " + (this.mTier * 5) + "% chance for extra drops", + "Holds " + this.getCapacity() + "L of Water", + GTPPCore.GT_Tooltip.get()); + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aStack) { + return true; + } + + /* + * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == + * aFacing) return 118+(aRedstone?8:0); if (GT_Utility.getOppositeSide(aSide) == aFacing) return + * 113+(aRedstone?8:0); int tIndex = 128+(aRedstone?8:0); switch (aFacing) { case 0: return tIndex+64; case 1: + * return tIndex+32; case 2: switch (aSide) { case 0: return tIndex+32; case 1: return tIndex+32; case 4: return + * tIndex+16; case 5: return tIndex+48; } case 3: switch (aSide) { case 0: return tIndex+64; case 1: return + * tIndex+64; case 4: return tIndex+48; case 5: return tIndex+16; } case 4: switch (aSide) { case 0: return + * tIndex+16; case 1: return tIndex+16; case 2: return tIndex+48; case 3: return tIndex+16; } case 5: switch (aSide) + * { case 0: return tIndex+48; case 1: return tIndex+48; case 2: return tIndex+16; case 3: return tIndex+48; } } + * return tIndex; } + */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getBack(i); + rTextures[7][i + 1] = this.getBottom(i); + rTextures[8][i + 1] = this.getTop(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) { + return this.mTextures[3][aColorIndex + 1]; + } else { + return this.mTextures[4][aColorIndex + 1]; + } + /* + * return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) + * ? 1 : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + */ + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_CropHarvester_Boxes) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_CropHarvester_Cutter) }; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mModeAlternative", this.mModeAlternative); + aNBT.setBoolean("mHarvestEnabled", this.mHarvestEnabled); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mModeAlternative = aNBT.getBoolean("mModeAlternative"); + if (aNBT.hasKey("mHarvestEnabled")) { + this.mHarvestEnabled = aNBT.getBoolean("mHarvestEnabled"); + } + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new CycleButtonWidget().setToggle(() -> mModeAlternative, val -> mModeAlternative = val) + .setTexture(GTPPUITextures.OVERLAY_BUTTON_HARVESTER_MODE) + .addTooltip(0, "Enable Hydration/Fertilizing/Weed-EX") + .addTooltip(1, "Disable Hydration/Fertilizing/Weed-EX") + .setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(47, 63) + .setSize(18, 18)); + builder.widget( + new CycleButtonWidget().setToggle(() -> mHarvestEnabled, val -> mHarvestEnabled = val) + .setTexture(GTPPUITextures.OVERLAY_BUTTON_HARVESTER_TOGGLE) + .addTooltip(0, "Enable Harvest") + .addTooltip(1, "Disable Harvest") + .setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(67, 63) + .setSize(18, 18)); + builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 2) + .startFromSlot(SLOT_WEEDEX_1) + .endAtSlot(SLOT_WEEDEX_2) + .applyForWidget( + widget -> widget.setFilter( + stack -> stack != null && stack.getItem() + .getUnlocalizedName() + .equals("ic2.itemWeedEx")) + .setBackground(getGUITextureSet().getItemSlot(), GTPPUITextures.OVERLAY_SLOT_WEED_EX)) + .build() + .setPos(7, 13)) + .widget( + SlotGroup.ofItemHandler(inventoryHandler, 2) + .startFromSlot(SLOT_FERT_1) + .endAtSlot(SLOT_FERT_4) + .applyForWidget( + widget -> widget.setFilter( + stack -> stack != null && stack.getItem() + .getUnlocalizedName() + .equals("ic2.itemFertilizer")) + .setBackground(getGUITextureSet().getItemSlot(), GTPPUITextures.OVERLAY_SLOT_FERTILIZER)) + .build() + .setPos(7, 31)) + .widget( + SlotGroup.ofItemHandler(inventoryHandler, 6) + .startFromSlot(SLOT_OUTPUT_START) + .endAtSlot(SLOT_OUTPUT_START + 6 * 3) + .canInsert(false) + .build() + .setPos(61, 7)); + builder + .widget( + new ProgressBar() + .setTexture(GTPPUITextures.PROGRESSBAR_BOILER_EMPTY, GTUITextures.PROGRESSBAR_BOILER_WATER, 54) + .setDirection(ProgressBar.Direction.UP) + .setProgress(() -> (float) getFluidAmount() / getCapacity()) + .setSynced(false, false) + .dynamicTooltip( + () -> Collections.singletonList("Water: " + getFluidAmount() + "L / " + getCapacity() + "L")) + .setPos(47, 7) + .setSize(10, 54)) + .widget(new FakeSyncWidget.FluidStackSyncer(this::getDrainableStack, this::setDrainableStack)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java new file mode 100644 index 0000000000..b87403d17e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java @@ -0,0 +1,459 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEPollutionCreator extends GTPPMetaTileEntity { + + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + + public MTEPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public MTEPollutionCreator(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "A useful debug machine to create pollution.", + GTPPCore.GT_Tooltip.get() }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (pollutionMultiplier > 99) { + pollutionMultiplier = 1; + } else { + pollutionMultiplier++; + } + PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now " + pollutionMultiplier + "."); + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEPollutionCreator( + this.mName, + this.mTier, + this.mDescription, + this.mTextures, + this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + public int pollutionMultiplier = 1; + + private void showPollution(final World worldIn, final EntityPlayer playerIn) { + if (!PollutionUtils.isPollutionEnabled()) { + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } else { + addPollution(); + PlayerUtils + .messagePlayer(playerIn, "This chunk now contains " + getCurrentChunkPollution() + " pollution."); + // PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" + // pollution."); + } + } + + private boolean addPollution() { + PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000 * pollutionMultiplier); + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution() { + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + @Override + public String[] getInfoData() { + return new String[] { this.getLocalName(), "Current Pollution: " + this.mCurrentPollution, + "Average/10 minutes:" + getAveragePollutionOverLastTen() }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity() + .isServerSide()) { + if (this.mCurrentPollution == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + if (this.mArrayPos < 0 || this.mArrayPos > 9) { + this.mArrayPos = 0; + } + this.mTickTimer = 0; + } + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity() + .isServerSide()) { + // TickTimer - 20 times a second + this.mTickTimer++; + if (mTickTimer % 20 == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + } + } + + public int getAveragePollutionOverLastTen() { + int counter = 0; + int total = 0; + + for (int j : this.mAveragePollutionArray) { + if (j != 0) { + total += j; + counter++; + } + } + int returnValue = 0; + if (total > 0 && counter > 0) { + returnValue = (total / counter); + this.mAveragePollution = returnValue; + } else { + returnValue = getCurrentChunkPollution(); + } + // Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" + // |"); + return returnValue; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java new file mode 100644 index 0000000000..6d599b60b9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java @@ -0,0 +1,503 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEPollutionDetector extends GTPPMetaTileEntity { + + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + private long mRedstoneLevel = 0; + + public MTEPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public MTEPollutionDetector(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Right click to check pollution levels.", + "Configure with screwdriver to set redstone output amount.", "Does not use power.", + GTPPCore.GT_Tooltip.get() }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return side == facing + ? new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GTRenderedTexture(Textures.BlockIcons.VOID) }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + /* + * @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final + * byte aFacing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { return + * this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 : side == facing.getOpposite() ? 1 : side == + * ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; } + */ + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEPollutionDetector( + this.mName, + this.mTier, + this.mDescription, + this.mTextures, + this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn) { + if (!PollutionUtils.isPollutionEnabled()) { + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } else { + PlayerUtils.messagePlayer(playerIn, "This chunk contains " + getCurrentChunkPollution() + " pollution."); + PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: " + this.mRedstoneLevel); + } + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution() { + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity) { + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + @Override + public String[] getInfoData() { + return new String[] { this.getLocalName(), "Current Pollution: " + this.mCurrentPollution, + "Average/10 Sec: " + this.mAveragePollution, "Emit Redstone at pollution level: " + this.mRedstoneLevel }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + public boolean allowCoverOnSide(final ForgeDirection side, final int aCoverID) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + // Only Calc server-side + if (!this.getBaseMetaTileEntity() + .isServerSide()) { + return; + } + // Emit Redstone + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + this.getBaseMetaTileEntity() + .setStrongOutputRedstoneSignal(side, (byte) 16); + } + this.markDirty(); + } else { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + this.getBaseMetaTileEntity() + .setStrongOutputRedstoneSignal(side, (byte) 0); + } + this.markDirty(); + } + + // Do Math for stats + if (this.mTickTimer % 20 == 0) { + mCurrentPollution = this.getCurrentChunkPollution(); + if (mArrayPos > mAveragePollutionArray.length - 1) { + mArrayPos = 0; + } + mAveragePollutionArray[mArrayPos] = mCurrentPollution; + mAveragePollution = getAveragePollutionOverLastTen(); + mArrayPos++; + } + this.mTickTimer++; + } + + public int getAveragePollutionOverLastTen() { + return MathUtils.getIntAverage(mAveragePollutionArray); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + if (side == this.getBaseMetaTileEntity() + .getFrontFacing()) { + final float[] tCoords = GTUtility.getClickedFacingCoords(side, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0 -> this.mRedstoneLevel -= 5000; + case 1 -> this.mRedstoneLevel += 5000; + case 2 -> this.mRedstoneLevel -= 50000; + case 3 -> this.mRedstoneLevel += 50000; + } + this.markDirty(); + GTUtility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); + } + + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowGeneralRedstoneOutput() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + this.markDirty(); + return true; + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel) { + this.markDirty(); + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java new file mode 100644 index 0000000000..1535140115 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java @@ -0,0 +1,672 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.GTValues; +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.BaseMetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; + +public class MTEWirelessCharger extends GTPPMetaTileEntity { + + private int mCurrentDimension = 0; + public int mMode = 0; + public boolean mLocked = true; + + public MTEWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public MTEWirelessCharger(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Can be locked to the owner by sneaking with a screwdriver", + "Can also be locked with a lock upgrade", "", "3 Modes, Long-Range, Local and Mixed.", + "Long-Range: Can supply 2A of power to a single player up to " + (GTValues.V[this.mTier] * 4) + "m away.", + "Local: Can supply several Amps to each player within " + this.mTier * 20 + "m.", + "Mixed: Provides both 2A of long range and 1A per player locally.", + "Mixed mode is more conservative of power and as a result only", + "Gets half the distances each singular mode gets.", GTPPCore.GT_Tooltip.get() }; + } + + public int getTier() { + return this.mTier; + } + + public int getMode() { + return this.mMode; + } + + public int getDimensionID() { + return this.mCurrentDimension; + } + + public Map getLocalMap() { + return this.mLocalChargingMap; + } + + public Map getLongRangeMap() { + return this.mWirelessChargingMap; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + if (aPlayer.isSneaking()) { + mLocked = !mLocked; + PlayerUtils.messagePlayer(aPlayer, mLocked ? "Locked to owner." : "Unlocked."); + return; + } + + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity() + .getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : this.getBaseMetaTileEntity() + .getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + if (this.mMode >= 2) { + this.mMode = 0; + } else { + this.mMode++; + } + if (this.mMode == 0) { + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Charge Mode."); + } else if (this.mMode == 1) { + PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Charge Mode."); + } + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEWirelessCharger( + this.mName, + this.mTier, + this.mDescription, + this.mTextures, + this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return GTValues.V[this.mTier] * 128; + } + + @Override + public int getCapacity() { + return (int) (GTValues.V[this.mTier] * 32); + } + + @Override + public long maxEUInput() { + return GTValues.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + if (this.mMode == 0) { + return 2; + } else if (this.mMode == 1) { + return this.mLocalChargingMap.size() * 8; + } else { + return ((this.mLocalChargingMap.size() * 4) + this.mWirelessChargingMap.size()); + } + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] { this.getLocalName() }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("mLocked", this.mLocked); + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mCurrentDimension", this.mCurrentDimension); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mLocked = aNBT.getBoolean("mLocked"); + this.mMode = aNBT.getInteger("mMode"); + this.mCurrentDimension = aNBT.getInteger("mCurrentDimension"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + private Map mWirelessChargingMap = new HashMap<>(); + private Map mLocalChargingMap = new HashMap<>(); + + private boolean isValidPlayer(EntityPlayer aPlayer) { + BaseMetaTileEntity aTile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); + if (mLocked || (aTile != null && aTile.privateAccess())) { + if (aPlayer.getUniqueID() + .equals(getBaseMetaTileEntity().getOwnerUuid())) { + return true; + } else { + return false; + } + } + return true; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity() + .isServerSide()) { + + if (this.mCurrentDimension != aBaseMetaTileEntity.getWorld().provider.dimensionId) { + this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId; + } + + if (aTick % 20 == 0) { + boolean mHasBeenMapped = this.equals(ChargingHelper.getEntry(getTileEntityPosition())); + if (!mHasBeenMapped) { + mHasBeenMapped = ChargingHelper.addEntry(getTileEntityPosition(), this); + } + + if (mHasBeenMapped && !aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + + if (this.mMode == 1 || this.mMode == 2) { + int tempRange = (this.mMode == 1 ? this.mTier * 20 : this.mTier * 10); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) + < tempRange) { + if (isValidPlayer(mTemp) + && !mLocalChargingMap.containsKey(mTemp.getDisplayName())) { + mLocalChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); + ChargingHelper.addValidPlayer(mTemp, this); + // PlayerUtils.messagePlayer(mTemp, "You have entered charging range. + // ["+tempRange+"m - Local]."); + } + } else { + if (mLocalChargingMap.containsKey(mTemp.getDisplayName())) { + if (mLocalChargingMap.remove(mTemp.getDisplayName()) != null) { + // PlayerUtils.messagePlayer(mTemp, "You have left charging range. + // ["+tempRange+"m - Local]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } + if (this.mMode == 0 || this.mMode == 2) { + int tempRange = (int) (this.mMode == 0 ? 4 * GTValues.V[this.mTier] + : 2 * GTValues.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) + <= tempRange) { + if (!mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { + if (isValidPlayer(mTemp)) { + mWirelessChargingMap.put(mTemp.getDisplayName(), mTemp.getPersistentID()); + ChargingHelper.addValidPlayer(mTemp, this); + PlayerUtils.messagePlayer( + mTemp, + "You have entered charging range. [" + tempRange + "m - Long-Range]."); + } + } + } else { + if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())) { + if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null) { + PlayerUtils.messagePlayer( + mTemp, + "You have left charging range. [" + tempRange + "m - Long Range]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } + /* + * if (this.mMode == 0 || this.mMode == 2){ int tempRange = (int) (this.mMode == 0 ? + * 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if + * (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < + * tempRange){ if (!mWirelessChargingMap.containsKey(mTemp)){ + * mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + * PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + * ChargingHelper.addValidPlayer(mTemp, this); } } else { if + * (mWirelessChargingMap.containsKey(mTemp)){ if (mWirelessChargingMap.remove(mTemp) != + * null){ PlayerUtils.messagePlayer(mTemp, + * "You have left charging range. ["+tempRange+"m]."); + * ChargingHelper.removeValidPlayer(mTemp, this); } } } } + */ + + } + } + } + } + } + } + + public BlockPos getTileEntityPosition() { + return new BlockPos( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getYCoord(), + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld()); + } + + public BlockPos getPositionOfEntity(Entity mEntity) { + if (mEntity == null) { + return null; + } + return EntityUtils.findBlockPosUnderEntity(mEntity); + } + + public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB) { + if (objectA == null || objectB == null) { + return 0f; + } + int[] objectArray1 = new int[] { objectA.xPos, objectA.yPos, objectA.zPos }; + int[] objectArray2 = new int[] { objectB.xPos, objectB.yPos, objectB.zPos }; + + final double distance = Math.sqrt( + (objectArray2[0] - objectArray1[0]) * (objectArray2[0] - objectArray1[0]) + + (objectArray2[1] - objectArray1[1]) * (objectArray2[1] - objectArray1[1]) + + (objectArray2[2] - objectArray1[2]) * (objectArray2[2] - objectArray1[2])); + return distance; + } + + @Override + public void onRemoval() { + + ChargingHelper.removeEntry(getTileEntityPosition(), this); + + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity() + .getWorld().playerEntities.isEmpty()) { + for (Object mTempPlayer : this.getBaseMetaTileEntity() + .getWorld().playerEntities) { + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP) { + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + super.onRemoval(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + + int tempRange; + + if (this.mMode == 0 || this.mMode == 2) { + tempRange = (int) (this.mMode == 0 ? 4 * GTValues.V[this.mTier] : 2 * GTValues.V[this.mTier]); + } else { + tempRange = this.mMode == 1 ? this.mTier * 20 : this.mTier * 10; + } + + if (this.mMode == 2) { + PlayerUtils + .messagePlayer(aPlayer, "Mixed Mode | Local: " + this.mTier * 10 + "m | Long: " + tempRange + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap() + .keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Local: " + name); + } + for (String name : this.getLongRangeMap() + .keySet()) { + PlayerUtils.messagePlayer(aPlayer, "Long: " + name); + } + } else if (this.mMode == 1) { + PlayerUtils.messagePlayer(aPlayer, "Local Mode: " + this.mTier * 20 + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLocalMap() + .keySet()) { + PlayerUtils.messagePlayer(aPlayer, "" + name); + } + + } else { + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: " + tempRange + "m"); + PlayerUtils.messagePlayer(aPlayer, "Players with access:"); + for (String name : this.getLongRangeMap() + .keySet()) { + PlayerUtils.messagePlayer(aPlayer, "" + name); + } + } + + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); + } + + @Override + public void onServerStart() { + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + super.onServerStart(); + } + + @Override + public void onExplosion() { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.onExplosion(); + } + + @Override + public void doExplosion(long aExplosionPower) { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.doExplosion(aExplosionPower); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java deleted file mode 100644 index 52804f9ad2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ /dev/null @@ -1,248 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; - -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.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -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 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 gregtech.api.enums.TAE; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - - private static final int MACHINEMODE_PACKAGER = 0; - private static final int MACHINEMODE_UNPACKAGER = 1; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GMTE_AmazonPackager(mName); - } - - public GMTE_AmazonPackager(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GMTE_AmazonPackager(String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Packager, Unpackager"; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GMTE_AmazonPackager.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(2, 9)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 9)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Amazon Warehouse") - .addInfo("This Multiblock is used for EXTREME packaging requirements") - .addInfo("Can be configured with a screwdriver to work as an Unpackager") - .addInfo("Dust Schematics are inserted into the input busses") - .addInfo("If inserted into the controller, it is shared across all busses") - .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") - .addInfo("500% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes 16 items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfoMin("Supply Depot Casings", 10, false) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher("GT++"); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAAmazonPackagerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAAmazonPackager; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(2, 9); - } - - @Override - public RecipeMap getRecipeMap() { - return (machineMode == MACHINEMODE_PACKAGER) ? RecipeMaps.packagerRecipes : RecipeMaps.unpackagerRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.packagerRecipes, RecipeMaps.unpackagerRecipes); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 6F) - .setEuModifier(0.75F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public int getMaxEfficiency(ItemStack p0) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack arg0) { - return CORE.ConfigSwitches.pollutionPerSecondMultiPackager; - } - - @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean supportsInputSeparation() { - return true; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mPackageMode")) { - machineMode = aNBT.getInteger("mPackageMode"); - } - super.loadNBTData(aNBT); - } - - @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); - tag.setInteger("mode", machineMode); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_PACKAGER.mode." + machineMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_PACKAGER.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_PACKAGER); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_UNPACKAGER); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/MTEAmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/MTEAmazonPackager.java new file mode 100644 index 0000000000..9f0b6d6be9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/MTEAmazonPackager.java @@ -0,0 +1,246 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; + +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +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 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 gregtech.api.enums.TAE; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEAmazonPackager extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + + private static final int MACHINEMODE_PACKAGER = 0; + private static final int MACHINEMODE_UNPACKAGER = 1; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAmazonPackager(mName); + } + + public MTEAmazonPackager(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAmazonPackager(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Packager, Unpackager"; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEAmazonPackager.class).atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(2, 9)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 9)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Amazon Warehouse") + .addInfo("This Multiblock is used for EXTREME packaging requirements") + .addInfo("Can be configured with a screwdriver to work as an Unpackager") + .addInfo("Dust Schematics are inserted into the input busses") + .addInfo("If inserted into the controller, it is shared across all busses") + .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") + .addInfo("500% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes 16 items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfoMin("Supply Depot Casings", 10, false) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher("GT++"); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAAmazonPackagerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAAmazonPackager; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(2, 9); + } + + @Override + public RecipeMap getRecipeMap() { + return (machineMode == MACHINEMODE_PACKAGER) ? RecipeMaps.packagerRecipes : RecipeMaps.unpackagerRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.packagerRecipes, RecipeMaps.unpackagerRecipes); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 6F) + .setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public int getMaxEfficiency(ItemStack p0) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack arg0) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiPackager; + } + + @Override + public int getMaxParallelRecipes() { + return (16 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mPackageMode")) { + machineMode = aNBT.getInteger("mPackageMode"); + } + super.loadNBTData(aNBT); + } + + @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); + tag.setInteger("mode", machineMode); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_PACKAGER.mode." + machineMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_PACKAGER.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_PACKAGER); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_UNPACKAGER); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java deleted file mode 100644 index e5d138dfda..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java +++ /dev/null @@ -1,223 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofCoil; - -import net.minecraft.item.ItemStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GregtechMetaTileEntity_IndustrialAlloySmelter extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - private HeatingCoilLevel mHeatingCapacity; - private int mLevel = 0; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialAlloySmelter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); - } - - public GregtechMetaTileEntity_IndustrialAlloySmelter(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialAlloySmelter(this.mName); - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.alloySmelterRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public String getMachineType() { - return "Alloy Smelter"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Alloy Smelter") - .addInfo("Gains one parallel per voltage tier") - .addInfo("Gains one multiplier per coil tier") - .addInfo("Parallel = Tier * Coil Tier") - .addInfo("Gains 5% speed bonus per coil tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 5, 3, true) - .addController("Bottom center") - .addCasingInfoMin("Inconel Reinforced Casings", 8, false) - .addOtherStructurePart("Integral Encasement V", "Middle Layer") - .addOtherStructurePart("Heating Coils", "Above and below Integral Encasements") - .addInputBus("Any Inconel Reinforced Casing", 1) - .addOutputBus("Any Inconel Reinforced Casing", 1) - .addEnergyHatch("Any Inconel Reinforced Casing", 1) - .addMaintenanceHatch("Any Inconel Reinforced Casing", 1) - .addMufflerHatch("Any Inconel Reinforced Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "VVV", "V-V", "VVV" }, - { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialAlloySmelter.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) - .addElement( - 'H', - ofCoil( - GregtechMetaTileEntity_IndustrialAlloySmelter::setCoilLevel, - GregtechMetaTileEntity_IndustrialAlloySmelter::getCoilLevel)) - .addElement('V', ofBlock(ModBlocks.blockCasingsTieredGTPP, 4)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mLevel = 0; - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 4, 0) && mCasing >= 8 - && getCoilLevel() != HeatingCoilLevel.None - && (mLevel = getCoilLevel().getTier() + 1) > 0 - && checkHatch(); - } - - @Override - public int getMaxParallelRecipes() { - return (this.mLevel * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return super.createOverclockCalculator(recipe).setSpeedBoost(100F / (100F + 5F * mLevel)) - .setHeatOC(true) - .setRecipeHeat(0) - // Need to multiply by 2 because heat OC is done only once every 1800 and this one does it once - // every - // 900 - .setMachineHeat((int) (getCoilLevel().getHeat() * 2)); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } - - @Override - public boolean isInputSeparationEnabled() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java deleted file mode 100644 index cc182cf6d2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ /dev/null @@ -1,359 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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 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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialArcFurnace - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - // 862 - private static final int mCasingTextureID = TAE.getIndexFromPage(3, 3); - public static String mCasingName = "Tempered Arc Furnace Casing"; - private boolean mPlasmaMode = false; - - private int mSize = 0; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialArcFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialArcFurnace(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialArcFurnace(this.mName); - } - - @Override - public String getMachineType() { - return "(Plasma/Electric) Arc Furnace"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for Industrial Arc Furnace") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes 8 * voltage tier * W items") - .addInfo("Right-click controller with a Screwdriver to change modes") - .addInfo("Max Size required to process Plasma recipes") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addController("Top center") - .addStructureInfo("Size: nxnx3 [WxHxL] (Hollow)") - .addStructureInfo("n can be 3, 5 or 7") - .addCasingInfoMin(mCasingName, 10, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - /** - * The front part of multi. Used to determine the tier, or in other words, determine the size of multi. - */ - private static final String STRUCTURE_PIECE_FRONT = "front"; - /** - * The rest part of multi. - */ - private static final String STRUCTURE_PIECE_REST = "rest"; - private static final int MAX_TIER = 3; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_FRONT + 1, new String[][] { { "CCC", "C~C", "CCC" } }) - .addShape(STRUCTURE_PIECE_FRONT + 2, new String[][] { { "CCCCC", "C C", "C C", "C C", "CCCCC" } }) - .addShape( - STRUCTURE_PIECE_FRONT + 3, - new String[][] { { "CCCCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCCCC" }, }) - .addShape(STRUCTURE_PIECE_REST + 1, new String[][] { { "CCC", "C-C", "CCC" }, { "CCC", "CCC", "CCC" } }) - .addShape( - STRUCTURE_PIECE_REST + 2, - new String[][] { { "CCCCC", "C---C", "C---C", "C---C", "CCCCC" }, - { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" } }) - .addShape( - STRUCTURE_PIECE_REST + 3, - new String[][] { { "CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC" }, - { "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC" }, }) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialArcFurnace.class) - .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .allowOnly(ForgeDirection.NORTH) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 3)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - private int getTierFromHint(ItemStack stackSize) { - if (stackSize.stackSize <= 0 || stackSize.stackSize >= MAX_TIER) { - return MAX_TIER; - } - return stackSize.stackSize; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - int maxTier = getTierFromHint(stackSize); - for (int tier = 1; tier <= maxTier; tier++) { - buildPiece(STRUCTURE_PIECE_FRONT + tier, stackSize, hintsOnly, tier, tier, 0); - } - buildPiece(STRUCTURE_PIECE_REST + maxTier, stackSize, hintsOnly, maxTier, maxTier, -1); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - int maxTier = getTierFromHint(stackSize); - int built; - for (int tier = 1; tier <= maxTier; tier++) { - built = survivialBuildPiece( - STRUCTURE_PIECE_FRONT + tier, - stackSize, - tier, - tier, - 0, - elementBudget, - env, - false, - true); - if (built >= 0) return built; - } - - return survivialBuildPiece( - STRUCTURE_PIECE_REST + maxTier, - stackSize, - maxTier, - maxTier, - -1, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mSize = 0; - int tier = 0; - while (tier < MAX_TIER && checkPiece(STRUCTURE_PIECE_FRONT + (tier + 1), (tier + 1), (tier + 1), 0)) { - tier++; - } - if (tier <= 0) return false; - if (checkPiece(STRUCTURE_PIECE_REST + tier, tier, tier, -1)) { - mSize = 2 * tier + 1; - return mCasing >= 10 && checkHatch(); - } - return false; - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialArcFurnaceActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialArcFurnace; - } - - @Override - protected int getCasingTextureId() { - return mCasingTextureID; - } - - @Override - public RecipeMap getRecipeMap() { - return mPlasmaMode ? RecipeMaps.plasmaArcFurnaceRecipes : RecipeMaps.arcFurnaceRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.arcFurnaceRecipes, RecipeMaps.plasmaArcFurnaceRecipes); - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3.5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (this.mSize * 8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings4Misc; - } - - public byte getCasingMeta() { - return 3; - } - - public byte getCasingTextureIndex() { - return (byte) mCasingTextureID; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (this.mSize > 5) { - this.mPlasmaMode = !mPlasmaMode; - if (mPlasmaMode) { - PlayerUtils.messagePlayer( - aPlayer, - "[" + EnumChatFormatting.RED - + "MODE" - + EnumChatFormatting.RESET - + "] " - + EnumChatFormatting.LIGHT_PURPLE - + "Plasma" - + EnumChatFormatting.RESET); - } else { - PlayerUtils.messagePlayer( - aPlayer, - "[" + EnumChatFormatting.RED - + "MODE" - + EnumChatFormatting.RESET - + "] " - + EnumChatFormatting.YELLOW - + "Electric" - + EnumChatFormatting.RESET); - } - } else { - PlayerUtils.messagePlayer( - aPlayer, - "[" + EnumChatFormatting.RED - + "MODE" - + EnumChatFormatting.RESET - + "] " - + EnumChatFormatting.GRAY - + "Cannot change mode, structure not large enough." - + EnumChatFormatting.RESET); - } - mLastRecipe = null; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mPlasmaMode", mPlasmaMode); - aNBT.setInteger("mSize", mSize); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mPlasmaMode = aNBT.getBoolean("mPlasmaMode"); - mSize = aNBT.getInteger("mSize"); - } - - @Override - public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, - int z) { - super.getWailaNBTData(player, tile, tag, world, x, y, z); - tag.setBoolean("mode", mPlasmaMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_ARC_FURNACE.mode." + (tag.getBoolean("mode") ? 1 : 0)) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java deleted file mode 100644 index c04620d4b4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ /dev/null @@ -1,228 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GregtechMetaTileEntity_IndustrialCentrifuge - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean mIsAnimated; - private static final CustomIcon frontFaceActive = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static final CustomIcon frontFace = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - // public static double recipesComplete = 0; - - public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - mIsAnimated = true; - } - - public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { - super(aName); - mIsAnimated = true; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); - } - - @Override - public String getMachineType() { - return "Centrifuge"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Centrifuge") - .addInfo("125% faster than using single block machines of the same voltage") - .addInfo("Disable animations with a screwdriver") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes six items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Centrifuge Casings", 6, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCentrifuge.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 0)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - if (usingAnimations()) { - return frontFaceActive; - } else { - return frontFace; - } - } - - @Override - protected IIconContainer getInactiveOverlay() { - return frontFace; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(0); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.centrifugeNonCellRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setEuModifier(0.9F) - .setSpeedBonus(1F / 2.25F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - public byte getCasingMeta() { - return 0; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(0); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - this.mIsAnimated = !mIsAnimated; - Logger.INFO("Is Centrifuge animated " + this.mIsAnimated); - if (this.mIsAnimated) { - PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture. "); - } else { - PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture. "); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mIsAnimated", mIsAnimated); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("mIsAnimated")) { - mIsAnimated = aNBT.getBoolean("mIsAnimated"); - } else { - mIsAnimated = true; - } - } - - public boolean usingAnimations() { - // Logger.INFO("Is animated? "+this.mIsAnimated); - return this.mIsAnimated; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java deleted file mode 100644 index 82d18a9347..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ /dev/null @@ -1,342 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import java.util.List; -import java.util.stream.Stream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; - -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 gregtech.api.enums.SoundResource; -import gregtech.api.interfaces.IIconContainer; -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_InputBus; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_StreamUtil; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ChiselBus; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import team.chisel.carving.Carving; - -public class GregtechMetaTileEntity_IndustrialChisel - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - - private ItemStack target; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - private ItemStack mInputCache; - private ItemStack mOutputCache; - private GT_Recipe mCachedRecipe; - - public GregtechMetaTileEntity_IndustrialChisel(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialChisel(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialChisel(this.mName); - } - - @Override - public String getMachineType() { - return "Chisel"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Auto Chisel") - .addInfo("Target block goes in Controller slot for common Input Buses") - .addInfo("You can also set a target block in each Chisel Input Bus and use them as an Input Bus") - .addInfo("If no target is provided for common buses, the result of the first chisel is used") - .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfoMin("Sturdy Printer Casing", 6, false) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - // spotless:off - new String[][] { - { "CCC", "CCC", "CCC" }, - { "C~C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC" }, - })) - // spotless:on - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialChisel.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(90) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 5)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialChiselActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialChisel; - } - - @Override - protected int getCasingTextureId() { - return 90; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { - if (mInputCache != null && mOutputCache != null && mCachedRecipe != null) { - if (GT_Utility.areStacksEqual(aStack, mInputCache) - && GT_Utility.areStacksEqual(aSpecialSlot, mOutputCache)) { - return true; - } - } - // clear cache if it was invalid - if (aClearOnFailure) { - mInputCache = null; - mOutputCache = null; - mCachedRecipe = null; - } - return false; - } - - private void cacheItem(ItemStack aInputItem, ItemStack aOutputItem, GT_Recipe aRecipe) { - mInputCache = aInputItem.copy(); - mOutputCache = aOutputItem.copy(); - mCachedRecipe = aRecipe; - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { - List results = getItemsForChiseling(from); - for (ItemStack s : results) { - if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { - return true; - } - } - return false; - } - - // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target - private static boolean hasChiselResults(ItemStack from) { - List results = getItemsForChiseling(from); - return results.size() > 0; - } - - private static List getItemsForChiseling(ItemStack aStack) { - return Carving.chisel.getItemsForChiseling(aStack); - } - - private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { - ItemStack tOutput; - if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { - tOutput = aTarget; - } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { - tOutput = null; - } else { - tOutput = getItemsForChiseling(aInput).get(0); - } - return tOutput; - } - - private GT_Recipe generateChiselRecipe(ItemStack aInput) { - boolean tIsCached = hasValidCache(aInput, this.target, true); - if (tIsCached || aInput != null && hasChiselResults(aInput)) { - ItemStack tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, this.target); - if (tOutput != null) { - if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) - && GT_Utility.areStacksEqual(tOutput, mOutputCache)) { - return mCachedRecipe; - } - // We can chisel this - GT_Recipe aRecipe = new GT_Recipe( - false, - new ItemStack[] { ItemUtils.getSimpleStack(aInput, 1) }, - new ItemStack[] { ItemUtils.getSimpleStack(tOutput, 1) }, - null, - new int[] { 10000 }, - new FluidStack[] {}, - new FluidStack[] {}, - 20, - 16, - 0); - - // Cache it - cacheItem(aInput, tOutput, aRecipe); - return aRecipe; - } - } - return null; - } - - private GT_Recipe getRecipe() { - for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { - if (bus instanceof GT_MetaTileEntity_ChiselBus) { // Chisel buses - if (bus.mInventory[bus.getSizeInventory() - 1] == null) continue; - this.target = bus.mInventory[bus.getSizeInventory() - 1]; - - for (int i = bus.getSizeInventory() - 2; i >= 0; i--) { - ItemStack itemsInSlot = bus.mInventory[i]; - if (itemsInSlot != null) { - GT_Recipe tRecipe = generateChiselRecipe(itemsInSlot); - if (tRecipe != null) { - return tRecipe; - } - } - } - } else { - target = this.getControllerSlot(); // Common buses - for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { - ItemStack itemsInSlot = bus.mInventory[i]; - if (itemsInSlot != null) { - GT_Recipe tRecipe = generateChiselRecipe(itemsInSlot); - if (tRecipe != null) { - return tRecipe; - } - } - } - } - - } - return null; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected Stream findRecipeMatches(@Nullable RecipeMap map) { - return GT_StreamUtil.ofNullable(getRecipe()); - } - }.setSpeedBonus(1F / 3F) - .setEuModifier(0.75F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void sendStartMultiBlockSoundLoop() { - sendLoopStart(PROCESS_START_SOUND_INDEX); - } - - @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - private static ResourceLocation sChiselSound = null; - - private static ResourceLocation getChiselSound() { - if (sChiselSound == null) { - sChiselSound = new ResourceLocation(Carving.chisel.getVariationSound(Blocks.stone, 0)); - } - return sChiselSound; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - switch (aIndex) { - case PROCESS_START_SOUND_INDEX -> GT_Utility - .doSoundAtClient(getChiselSound(), getTimeBetweenProcessSounds(), 1.0F, 1.0F, aX, aY, aZ); - case INTERRUPT_SOUND_INDEX -> GT_Utility - .doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); - } - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java deleted file mode 100644 index a20b879fb8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ /dev/null @@ -1,209 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialCokeOven - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mLevel = 0; - private int mCasing; - private int mCasing1; - private int mCasing2; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); - } - - @Override - public String getMachineType() { - return "Coke Oven"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Processes Logs and Coal into Charcoal and Coal Coke.") - .addInfo("Controller Block for the Industrial Coke Oven") - .addInfo("Gain 4% energy discount per voltage tier") - .addInfo("Process 12x materials with Heat Resistant Casings") - .addInfo("Or 24x materials with Heat Proof Casings") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front middle at bottom") - .addCasingInfoMin("Structural Coke Oven Casings", 8, false) - .addCasingInfoMin("Heat Resistant/Proof Coke Oven Casings", 8, false) - .addInputBus("Any Structural Coke Oven Casing", 1) - .addOutputBus("Any Structural Coke Oven Casing", 1) - .addInputHatch("Any Structural Coke Oven Casing", 1) - .addOutputHatch("Any Structural Coke Oven Casing", 1) - .addEnergyHatch("Any Structural Coke Oven Casing", 1) - .addMaintenanceHatch("Any Structural Coke Oven Casing", 1) - .addMufflerHatch("Any Structural Coke Oven Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) - .addShape( - mName + "1", - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "aaa", "a-a", "aaa" }, { "C~C", "CCC", "CCC" }, })) - .addShape( - mName + "2", - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "bbb", "b-b", "bbb" }, { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCokeOven.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(1)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 1)))) - .addElement( - 'H', - ofChain( - onElementPass(x -> ++x.mCasing1, ofBlock(ModBlocks.blockCasingsMisc, 2)), - onElementPass(x -> ++x.mCasing2, ofBlock(ModBlocks.blockCasingsMisc, 3)))) - .addElement('a', ofBlock(ModBlocks.blockCasingsMisc, 2)) - .addElement('b', ofBlock(ModBlocks.blockCasingsMisc, 3)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - if (stackSize.stackSize == 1) buildPiece(mName + "1", stackSize, hintsOnly, 1, 2, 0); - else buildPiece(mName + "2", stackSize, hintsOnly, 1, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - if (stackSize.stackSize == 1) - return survivialBuildPiece(mName + "1", stackSize, 1, 2, 0, elementBudget, env, false, true); - else return survivialBuildPiece(mName + "2", stackSize, 1, 2, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mCasing1 = 0; - mCasing2 = 0; - mLevel = 0; - if (checkPiece(mName, 1, 2, 0)) { - if (mCasing1 == 8) mLevel = 1; - if (mCasing2 == 8) mLevel = 2; - return mLevel > 0 && mCasing >= 8 && checkHatch(); - } - return false; - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCACokeOvenActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCACokeOven; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(1); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.cokeOvenRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void setupProcessingLogic(ProcessingLogic logic) { - super.setupProcessingLogic(logic); - logic.setEuModifier((100F - (GT_Utility.getTier(getMaxInputVoltage()) * 4)) / 100F); - } - - @Override - public int getMaxParallelRecipes() { - return this.mLevel * 12; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java deleted file mode 100644 index 4910ee4d2f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ /dev/null @@ -1,270 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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 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 gregtech.api.enums.TAE; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialCuttingMachine extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static final int MACHINEMODE_CUTTER = 0; - private static final int MACHINEMODE_SLICER = 1; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialCuttingMachine(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCuttingMachine(this.mName); - } - - @Override - public String getMachineType() { - return "Cutting Machine / Slicing Machine"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Cutting Factory") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfoMin("Cutting Factory Frames", 14, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialCuttingMachine.class) - .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 13)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialCuttingMachineActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialCuttingMachine; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(29); - } - - @Override - public RecipeMap getRecipeMap() { - return (machineMode == MACHINEMODE_CUTTER) ? RecipeMaps.cutterRecipes : RecipeMaps.slicerRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.cutterRecipes, RecipeMaps.slicerRecipes); - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3F) - .setEuModifier(0.75F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean isInputSeparationEnabled() { - return true; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 13; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(29); - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_CUTTING); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_SLICING); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_CUTTING_MACHINE.mode." + machineMode); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - // Migrates old NBT tag to the new one - if (aNBT.hasKey("mCuttingMode")) { - machineMode = aNBT.getBoolean("mCuttingMode") ? MACHINEMODE_CUTTER : MACHINEMODE_SLICER; - } - super.loadNBTData(aNBT); - } - - @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); - tag.setInteger("mode", machineMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_CUTTING_MACHINE.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java deleted file mode 100644 index f4b10890c8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ /dev/null @@ -1,278 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofCoil; - -import java.util.Arrays; -import java.util.Collection; -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.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_Recipe; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialDehydrator - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private static int CASING_TEXTURE_ID; - private static String mCasingName = "Vacuum Casing"; - private HeatingCoilLevel mHeatingCapacity; - private boolean mDehydratorMode = false; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialDehydrator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); - } - - public GregtechMetaTileEntity_IndustrialDehydrator(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialDehydrator(mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Vacuum Furnace") - .addInfo("Can toggle the operation temperature with a Screwdriver") - .addInfo("All Dehydrator recipes are Low Temp recipes") - .addInfo("Speed: +120% | EU Usage: 50% | Parallel: 4") - .addInfo("Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)") - .addInfo("Each 1800K over the min. Heat Capacity allows for one upgraded overclock") - .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 5, 3, true) - .addController("Bottom Center") - .addCasingInfoMin(mCasingName, 5, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, - { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialDehydrator.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 10)))) - .addElement( - 'H', - ofCoil( - GregtechMetaTileEntity_IndustrialDehydrator::setCoilLevel, - GregtechMetaTileEntity_IndustrialDehydrator::getCoilLevel)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 4, 0) && mCasing >= 5 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialDehydratorActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialDehydrator; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return mDehydratorMode ? GTPPRecipeMaps.chemicalDehydratorNonCellRecipes : GTPPRecipeMaps.vacuumFurnaceRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(GTPPRecipeMaps.chemicalDehydratorNonCellRecipes, GTPPRecipeMaps.vacuumFurnaceRecipes); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; - } - - @Override - public String getMachineType() { - return "Vacuum Furnace / Dehydrator"; - } - - @Override - public int getMaxParallelRecipes() { - return 4; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL - : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); - } - - @NotNull - @Override - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return super.createOverclockCalculator(recipe).setHeatOC(true) - .setHeatDiscount(true) - .setRecipeHeat(recipe.mSpecialValue) - .setMachineHeat((int) getCoilLevel().getHeat()); - } - }.setSpeedBonus(1F / 2.2F) - .setEuModifier(0.5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mDehydratorMode = !mDehydratorMode; - String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace"; - PlayerUtils.messagePlayer(aPlayer, "Mode: " + aMode); - mLastRecipe = null; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mDehydratorMode", mDehydratorMode); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mDehydratorMode = aNBT.getBoolean("mDehydratorMode"); - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } - - @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); - tag.setBoolean("mode", mDehydratorMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector - .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_DEHYDRATOR.mode." + (tag.getBoolean("mode") ? 1 : 0)) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java deleted file mode 100644 index cf03c6aae9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ /dev/null @@ -1,169 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialElectrolyzer extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); - } - - @Override - public String getMachineType() { - return "Electrolyzer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Electrolyzer") - .addInfo("180% faster than using single block machines of the same voltage") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes two items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Electrolyzer Casings", 6, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialElectrolyzer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(TAE.GTPP_INDEX(5)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 5)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialElectrolyzerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialElectrolyzer; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(5); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.electrolyzerNonCellRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2.8F) - .setEuModifier(0.9F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 2 * GT_Utility.getTier(this.getMaxInputVoltage()); - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java deleted file mode 100644 index 9114fb5eac..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ /dev/null @@ -1,194 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialExtruder - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialExtruder(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialExtruder(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialExtruder(this.mName); - } - - @Override - public String getMachineType() { - return "Extruder"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Material Extruder") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes four items per voltage tier") - .addInfo("Extrusion Shape for recipe goes in the Input Bus") - .addInfo("Each Input Bus can have a different shape!") - .addInfo("You can use several input buses per multiblock") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfoMin("Inconel Reinforced Casings", 14, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialExtruder.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialExtruderActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialExtruder; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(33); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.extruderRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3.5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta() { - return 1; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(33); - } - - @Override - public boolean isInputSeparationEnabled() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java deleted file mode 100644 index 254402d4c1..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java +++ /dev/null @@ -1,204 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialFluidHeater extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing1; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialFluidHeater(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialFluidHeater(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialFluidHeater(this.mName); - } - - @Override - public String getMachineType() { - return "Fluid Heater"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Fluid Heater") - .addInfo("120% faster than using single block machines of the same voltage") - .addInfo("Only uses 90% of the EU/t normally required") - .addInfo("Processes eight items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 6, 5, true) - .addController("Front Center") - .addCasingInfoMin("Top/Bottom layer: Multi-use Casings", 34, false) - .addCasingInfoMin("Middle layers: Thermal Containment Casing", 47, false) - .addInputBus("Bottom Layer (optional)", 1) - .addInputHatch("Bottom Layer", 1) - .addOutputBus("Top Layer (optional)", 1) - .addOutputHatch("Top Layer", 1) - .addEnergyHatch("Any Multi-use Casing", 1) - .addMaintenanceHatch("Any Multi-use Casing", 1) - .addMufflerHatch("Any Multi-use Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { " TTT ", "TTTTT", "TTTTT", "TTTTT", " TTT " }, - { " XXX ", "X---X", "X---X", "X---X", " XXX " }, - { " XXX ", "X---X", "X---X", "X---X", " XXX " }, - { " XXX ", "X---X", "X---X", "X---X", " XXX " }, - { " X~X ", "X---X", "X---X", "X---X", " XXX " }, - { " BBB ", "BBBBB", "BBBBB", "BBBBB", " BBB " }, })) - .addElement( - 'B', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) - .atLeast(InputBus, InputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) - .addElement('X', ofBlock(getCasingBlock1(), getCasingMeta1())) - .addElement( - 'T', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFluidHeater.class) - .atLeast(OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 2, 4, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 4, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing1 = 0; - boolean didBuild = checkPiece(mName, 2, 4, 0); - log("Built? " + didBuild + ", " + mCasing1); - return didBuild && mCasing1 >= 34 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAFluidHeaterActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAFluidHeater; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 1); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.fluidHeaterRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2.2F) - .setEuModifier(0.9F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock1() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta1() { - return 11; - } - - public Block getCasingBlock2() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta2() { - return 2; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.getIndexFromPage(2, 2); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java deleted file mode 100644 index 44484cb90e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java +++ /dev/null @@ -1,244 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.enums.Mods.EnderIO; -import static gregtech.api.enums.Mods.Railcraft; -import static gregtech.api.enums.Mods.ThaumicBases; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; - -import org.apache.commons.lang3.tuple.Pair; - -import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; -import com.gtnewhorizon.structurelib.structure.ITierConverter; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("SpellCheckingInspection") -public class GregtechMetaTileEntity_IndustrialForgeHammer extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private int mAnvilTier = 0; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialForgeHammer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialForgeHammer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialForgeHammer(this.mName); - } - - @Override - public String getMachineType() { - return "Forge Hammer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Forge Hammer") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: Tier x Anvil Tier x 8") - .addInfo("T1 - Vanilla Anvil"); - if (Railcraft.isModLoaded()) { - tt.addInfo("T2 - Steel Anvil"); - } - if (EnderIO.isModLoaded()) { - tt.addInfo("T3 - Dark Steel Anvil"); - } - if (ThaumicBases.isModLoaded()) { - tt.addInfo("T3 - Thaumium Anvil"); - tt.addInfo("T4 - Void Metal Anvil"); - } - - tt.addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Forge Casing", 6, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addOtherStructurePart("Anvil", "In the center of 3x3x3 structure", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - Map anvilTiers = new HashMap<>(); - - anvilTiers.put(Blocks.anvil, 1); - - if (Railcraft.isModLoaded()) { - anvilTiers.put(GameRegistry.findBlock(Railcraft.ID, "anvil"), 2); - } - - if (EnderIO.isModLoaded()) { - anvilTiers.put(GameRegistry.findBlock(EnderIO.ID, "blockDarkSteelAnvil"), 3); - } - - if (ThaumicBases.isModLoaded()) { - anvilTiers.put(GameRegistry.findBlock(ThaumicBases.ID, "thaumicAnvil"), 3); - anvilTiers.put(GameRegistry.findBlock(ThaumicBases.ID, "voidAnvil"), 4); - } - - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "CAC", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialForgeHammer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(TAE.getIndexFromPage(1, 11)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6)))) - .addElement( - 'A', - ofBlocksTiered( - anvilTierConverter(anvilTiers), - getAllAnvilTiers(anvilTiers), - 0, - GregtechMetaTileEntity_IndustrialForgeHammer::setAnvilTier, - GregtechMetaTileEntity_IndustrialForgeHammer::getAnvilTier)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - private static List> getAllAnvilTiers(Map anvilTiers) { - return anvilTiers.entrySet() - .stream() - .map(e -> Pair.of(e.getKey(), e.getValue())) - .collect(Collectors.toList()); - } - - private static ITierConverter anvilTierConverter(Map anvilTiers) { - return (block, meta) -> block == null ? 0 : anvilTiers.getOrDefault(block, 0); - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.RANDOM_ANVIL_USE; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialForgeHammerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialForgeHammer; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(1, 11); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.hammerRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1 / 2F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * getAnvilTier() * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialForgeHammer; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private void setAnvilTier(int tier) { - mAnvilTier = tier; - } - - private int getAnvilTier() { - return mAnvilTier; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java deleted file mode 100644 index ff66b930ad..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java +++ /dev/null @@ -1,390 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -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.world.World; -import net.minecraftforge.common.util.Constants.NBT; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.tuple.Pair; - -import com.google.common.collect.ImmutableList; -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 gregtech.api.GregTech_API; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.IDualInputHatch; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialMacerator - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int controllerTier = 1; - private int structureTier; - private int mCasing; - - private static final String STRUCTURE_PIECE_MAIN = "main"; - - private static final int HORIZONTAL_OFF_SET = 1; - private static final int VERTICAL_OFF_SET = 5; - private static final int DEPTH_OFF_SET = 0; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static int getStructureCasingTier(Block b, int m) { - if (b == GregTech_API.sBlockCasings4 && m == 2) return 1; - if (b == ModBlocks.blockCasingsMisc && m == 7) return 2; - return 0; - } - - public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); - } - - @Override - public String getMachineType() { - return "Macerator/Pulverizer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller block for the Industrial Maceration Stack") - .addInfo("60% faster than using single block machines of the same voltage") - .addInfo("Maximum of n*tier parallels, LV = Tier 1, MV = Tier 2, etc.") - .addInfo("n=2 initially. n=8 after inserting Maceration Upgrade Chip.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 6, 3, true) - .addController("Bottom center") - .addCasingInfoMin("Maceration Stack Casings (After upgrade)", 26, false) - .addCasingInfoMin("Stable Titanium Casings (Before upgrade)", 26, false) - .addInputBus("Bottom casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addOutputBus("One per layer except bottom layer", 2) - .addMufflerHatch("Any casing except bottom layer", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - STRUCTURE_PIECE_MAIN, - // spotless:off - transpose( - new String[][] { - {"AAA","AAA","AAA"}, - {"AAA","A A","AAA"}, - {"AAA","A A","AAA"}, - {"AAA","A A","AAA"}, - {"AAA","A A","AAA"}, - {"A~A","AAA","AAA"} })) - //spotless:on - .addElement( - 'A', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialMacerator.class) - .atLeast(Energy, Maintenance, InputBus, Muffler, OutputBus) - .casingIndex(GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings4, 2)) - .allowOnly(ForgeDirection.NORTH) - .dot(1) - .build(), - onElementPass( - m -> m.mCasing++, - ofBlocksTiered( - GregtechMetaTileEntity_IndustrialMacerator::getStructureCasingTier, - ImmutableList.of( - Pair.of(GregTech_API.sBlockCasings4, 2), - Pair.of(ModBlocks.blockCasingsMisc, 7)), - -1, - (m, t) -> m.structureTier = t, - m -> m.structureTier)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - this.buildPiece( - STRUCTURE_PIECE_MAIN, - stackSize, - hintsOnly, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - return survivialBuildPiece( - STRUCTURE_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - structureTier = -1; - if (!checkPiece(STRUCTURE_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (structureTier < 1 || mCasing < 26 || !checkHatch()) return false; - updateHatchTexture(); - return structureTier >= controllerTier; - } - - protected void updateHatchTexture() { - int textureID = getCasingTextureId(); - for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(textureID); - for (IDualInputHatch h : mDualInputHatches) h.updateTexture(textureID); - for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(textureID); - for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(textureID); - for (GT_MetaTileEntity_Hatch h : mMufflerHatches) h.updateTexture(textureID); - for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(textureID); - } - - @Override - public boolean checkHatch() { - return !mMufflerHatches.isEmpty() && !mMaintenanceHatches.isEmpty() - && !mOutputBusses.isEmpty() - && (!mInputBusses.isEmpty() || !mDualInputHatches.isEmpty()); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_MACERATOR_OP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab; - } - - @Override - protected int getCasingTextureId() { - if (structureTier == 2) return TAE.GTPP_INDEX(7); - return GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings4, 2); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.maceratorRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -10; - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) - && (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP) - && (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0) - && (!aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP))) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld() - .spawnParticle( - "smoke", - (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), - aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), - (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), - 0.0D, - 0.0D, - 0.0D); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == 0 && controllerTier == 1) { - ItemStack aGuiStack = this.getControllerSlot(); - if (GregtechItemList.Maceration_Upgrade_Chip.isStackEqual(aGuiStack, false, true)) { - controllerTier = 2; - mInventory[1] = ItemUtils.depleteStack(aGuiStack); - markDirty(); - // schedule a structure check - mUpdated = true; - } - } - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { - if (controllerTier == 1 && !aPlayer.isSneaking()) { - ItemStack heldItem = aPlayer.getHeldItem(); - if (GregtechItemList.Maceration_Upgrade_Chip.isStackEqual(heldItem, false, true)) { - controllerTier = 2; - aPlayer.setCurrentItemOrArmor(0, ItemUtils.depleteStack(heldItem)); - if (getBaseMetaTileEntity().isServerSide()) { - markDirty(); - aPlayer.inventory.markDirty(); - // schedule a structure check - mUpdated = true; - } - return true; - } - } - return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - } - - @Override - public void onValueUpdate(byte aValue) { - structureTier = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) structureTier; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setByte("mTier", (byte) controllerTier); - aNBT.setByte("structureTier", (byte) structureTier); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (!aNBT.hasKey("mTier", NBT.TAG_BYTE)) - // we assume old macerators are all T2 variants, as they were made before price reduction and shouldn't need - // to worry about upgrading - controllerTier = 2; - else controllerTier = aNBT.getByte("mTier"); - - structureTier = aNBT.getByte("structureTier"); - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - super.initDefaultModes(aNBT); - if (aNBT == null || !aNBT.hasKey("mTier")) { - controllerTier = 1; - } else { - controllerTier = aNBT.getByte("mTier"); - } - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - aNBT.setByte("mTier", (byte) controllerTier); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 1.6F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - final long tVoltage = getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - return Math.max(1, (controllerTier == 1 ? 2 : 8) * tTier); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } - - @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); - tag.setInteger("tier", controllerTier); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - if (tag.hasKey("tier")) { - currentTip.add( - "Tier: " + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(tag.getInteger("tier")) - + EnumChatFormatting.RESET); - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java deleted file mode 100644 index 39b5d6e73e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java +++ /dev/null @@ -1,211 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; - -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 gregtech.api.GregTech_API; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialMixer - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mCasingName = "Multi-Use Casing"; - public static String mCasingName2 = "Titanium Turbine Casing"; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialMixer(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); - } - - public GregtechMetaTileEntity_IndustrialMixer(final String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - if (aNBT.hasKey("isBussesSeparate")) { - inputSeparation = aNBT.getBoolean("isBussesSeparate"); - } - // Fallback for existing mixers - else { - inputSeparation = true; - } - } - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMixer(this.mName); - } - - @Override - public String getMachineType() { - return "Mixer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Mixer") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Processes eight recipes per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, false) - .addController("Second Layer Center") - .addCasingInfoMin(mCasingName, 6, false) - .addCasingInfoMin(mCasingName2, 2, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "CCC", "CMC", "CCC" }, { "C~C", "CMC", "CCC" }, - { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialMixer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) - .addElement('M', ofBlock(GregTech_API.sBlockCasings4, 11)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 2, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 2, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialMixerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialMixer; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.mixerNonCellRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3.5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; - } - - @Override - public void onModeChangeByScrewdriver(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 explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java deleted file mode 100644 index f40e851c55..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java +++ /dev/null @@ -1,241 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.GregTech_API; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialMolecularTransformer - extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private static final int CASING_TEXTURE_ID = 48; - private int mCasing = 0; - - public GregtechMetaTileEntity_IndustrialMolecularTransformer(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialMolecularTransformer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMolecularTransformer(this.mName); - } - - @Override - public String getMachineType() { - return "Molecular Transformer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Changes the structure of items to produce new ones") - .addInfo("Maximum 1x of each bus/hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 7, 7, false) - .addController("Top Center") - .addCasingInfoMin("Robust Tungstensteel Machine Casing", 40, false) - .addCasingInfoMin("Tungstensteel Coils", 16, false) - .addCasingInfoMin("Molecular Containment Casing", 52, false) - .addCasingInfoMin("High Voltage Current Capacitor", 32, false) - .addCasingInfoMin("Particle Containment Casing", 4, false) - .addCasingInfoMin("Resonance Chamber I", 5, false) - .addCasingInfoMin("Modulator I", 4, false) - .addInputBus("Any Robust Tungstensteel Machine Casing", 1) - .addOutputBus("Any Robust Tungstensteel Machine Casing", 1) - .addEnergyHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMaintenanceHatch("Any Robust Tungstensteel Machine Casing", 1) - .addMufflerHatch("Any Robust Tungstensteel Machine Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - STRUCTURE_PIECE_MAIN, - (new String[][] { { " ", " ", " xxx ", " x~x ", " xxx ", " ", " " }, - { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, - { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, - { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, - { " t ", " ttxtt ", " tyyyt ", "txyzyxt", " tyyyt ", " ttxtt ", " t " }, - { " c ", " ccecc ", " cxfxc ", "cefefec", " cxfxc ", " ccecc ", " c " }, - { " h ", " hhhhh ", " hhhhh ", "hhhhhhh", " hhhhh ", " hhhhh ", " h " }, })) - .addElement('x', ofBlock(getCasingBlock(), getCasingMeta())) - .addElement('y', ofBlock(getCasingBlock(), getCasingMeta2())) - .addElement('z', ofBlock(getCasingBlock(), getCasingMeta3())) - .addElement('e', ofBlock(getCasingBlock2(), 0)) - .addElement('f', ofBlock(getCasingBlock2(), 4)) - .addElement('c', ofBlock(getCoilBlock(), 3)) - .addElement('t', ofBlock(getCasingBlock3(), getTungstenCasingMeta())) - .addElement( - 'h', - buildHatchAdder(GregtechMetaTileEntity_IndustrialMolecularTransformer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain( - onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock3(), getTungstenCasingMeta())))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); - if (this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 1 || this.mEnergyHatches.size() != 1) { - return false; - } - // there are 16 slot that only allow casing, so we subtract this from the grand total required - return aDidBuild && mCasing >= 40 - 16 && checkHatch(); - } - - protected static int getCasingTextureIndex() { - return CASING_TEXTURE_ID; - } - - protected static Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - protected static Block getCasingBlock2() { - return ModBlocks.blockSpecialMultiCasings2; - } - - protected static Block getCasingBlock3() { - return GregTech_API.sBlockCasings4; - } - - protected static Block getCoilBlock() { - return GregTech_API.sBlockCasings5; - } - - protected static int getCasingMeta() { - return 11; - } - - protected static int getCasingMeta2() { - return 12; - } - - protected static int getCasingMeta3() { - return 13; - } - - protected static int getTungstenCasingMeta() { - return 0; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d == ForgeDirection.UP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialMolecularTransformerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialMolecularTransformer; - } - - @Override - protected int getCasingTextureId() { - return 44; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.molecularTransformerRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic(); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java deleted file mode 100644 index d9a9a1549a..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ /dev/null @@ -1,541 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -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 java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -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 net.minecraftforge.fluids.FluidStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IIconContainer; -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_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; -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_LanguageManager; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_CraftingInput_ME; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME; -import gregtech.common.tileentities.machines.IDualInputHatch; -import gregtech.common.tileentities.machines.IDualInputInventory; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Solidifier; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialMultiMachine extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private final static int MACHINEMODE_METAL = 0; - private final static int MACHINEMODE_FLUID = 1; - private final static int MACHINEMODE_MISC = 2; - - private static final int MODE_COMPRESSOR = 0; - private static final int MODE_LATHE = 1; - private static final int MODE_MAGNETIC = 2; - private static final int MODE_FERMENTER = 3; - private static final int MODE_FLUIDEXTRACT = 4; - private static final int MODE_EXTRACTOR = 5; - private static final int MODE_LASER = 6; - private static final int MODE_AUTOCLAVE = 7; - private static final int MODE_FLUIDSOLIDIFY = 8; - private static final int[][] MODE_MAP = new int[][] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; - public static final String[] aToolTipNames = new String[9]; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - static { - for (int id = 0; id < 9; id++) { - RecipeMap recipeMap = getRecipeMap(id); - if (recipeMap != null) { - String aNEI = GT_LanguageManager.getTranslation(getRecipeMap(id).unlocalizedName); - aToolTipNames[id] = aNEI != null ? aNEI : "BAD NEI NAME (Report to Github)"; - } - } - } - - public GregtechMetaTileEntity_IndustrialMultiMachine(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialMultiMachine(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMultiMachine(this.mName); - } - - @Override - public String getMachineType() { - return "Nine in One"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - String[] aBuiltStrings = new String[3]; - aBuiltStrings[0] = aToolTipNames[0] + ", " + aToolTipNames[1] + ", " + aToolTipNames[2]; - aBuiltStrings[1] = aToolTipNames[3] + ", " + aToolTipNames[4] + ", " + aToolTipNames[5]; - aBuiltStrings[2] = aToolTipNames[6] + ", " + aToolTipNames[7] + ", " + aToolTipNames[8]; - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Multi-Machine") - .addInfo("250% faster than using single block machines of the same voltage") - .addInfo("Only uses 80% of the EU/t normally required") - .addInfo("Processes two items per voltage tier") - .addInfo("Machine Type: Metal - " + EnumChatFormatting.YELLOW + aBuiltStrings[0] + EnumChatFormatting.RESET) - .addInfo("Machine Type: Fluid - " + EnumChatFormatting.YELLOW + aBuiltStrings[1] + EnumChatFormatting.RESET) - .addInfo("Machine Type: Misc - " + EnumChatFormatting.YELLOW + aBuiltStrings[2] + EnumChatFormatting.RESET) - .addInfo("Read Multi-Machine Manual for extra information") - .addInfo( - EnumChatFormatting.AQUA + "You can use Solidifier Hatch to solidify multiple liquids." - + EnumChatFormatting.RESET) - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Multi-Use Casings", 6, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialMultiMachine.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(getTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialMultiMachineActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialMultiMachine; - } - - @Override - protected int getCasingTextureId() { - return getTextureIndex(); - } - - @Override - public int getMaxParallelRecipes() { - return (2 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - switch (machineMode) { - case MACHINEMODE_METAL -> { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; - } - case MACHINEMODE_FLUID -> { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; - } - default -> { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; - } - } - } - - public int getTextureIndex() { - return TAE.getIndexFromPage(2, 2); - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - private ItemStack getCircuit(ItemStack[] t) { - for (ItemStack j : t) { - if (j.getItem() == GT_Utility.getIntegratedCircuit(0) - .getItem()) { - if (j.getItemDamage() >= 20 && j.getItemDamage() <= 22) { - return j; - } - } - } - return null; - } - - private int getCircuitID(ItemStack circuit) { - int H = circuit.getItemDamage(); - int T = (H == 20 ? 0 : (H == 21 ? 1 : (H == 22 ? 2 : -1))); - return MODE_MAP[machineMode][T]; - } - - @Override - public RecipeMap getRecipeMap() { - return null; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList( - RecipeMaps.compressorRecipes, - RecipeMaps.latheRecipes, - RecipeMaps.polarizerRecipes, - RecipeMaps.fermentingRecipes, - RecipeMaps.fluidExtractionRecipes, - RecipeMaps.extractorRecipes, - RecipeMaps.laserEngraverRecipes, - RecipeMaps.autoclaveRecipes, - RecipeMaps.fluidSolidifierRecipes); - } - - @Override - public int getRecipeCatalystPriority() { - return -10; - } - - private static RecipeMap getRecipeMap(int aMode) { - if (aMode == MODE_COMPRESSOR) { - return RecipeMaps.compressorRecipes; - } else if (aMode == MODE_LATHE) { - return RecipeMaps.latheRecipes; - } else if (aMode == MODE_MAGNETIC) { - return RecipeMaps.polarizerRecipes; - } else if (aMode == MODE_FERMENTER) { - return RecipeMaps.fermentingRecipes; - } else if (aMode == MODE_FLUIDEXTRACT) { - return RecipeMaps.fluidExtractionRecipes; - } else if (aMode == MODE_EXTRACTOR) { - return RecipeMaps.extractorRecipes; - } else if (aMode == MODE_LASER) { - return RecipeMaps.laserEngraverRecipes; - } else if (aMode == MODE_AUTOCLAVE) { - return RecipeMaps.autoclaveRecipes; - } else if (aMode == MODE_FLUIDSOLIDIFY) { - return RecipeMaps.fluidSolidifierRecipes; - } else { - return null; - } - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - private ItemStack lastCircuit = null; - private int lastMode = -1; - - @Nonnull - @Override - protected Stream findRecipeMatches(@Nullable RecipeMap map) { - ItemStack circuit = getCircuit(inputItems); - if (circuit == null) { - return Stream.empty(); - } - if (!GT_Utility.areStacksEqual(circuit, lastCircuit)) { - lastRecipe = null; - lastCircuit = circuit; - } - if (machineMode != lastMode) { - lastRecipe = null; - lastMode = machineMode; - } - RecipeMap foundMap = getRecipeMap(getCircuitID(circuit)); - if (foundMap == null) { - return Stream.empty(); - } - return super.findRecipeMatches(foundMap); - } - }.setSpeedBonus(1F / 3.5F) - .setEuModifier(0.8F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_MULTI_MACHINE.mode." + machineMode); - } - - @Override - public String[] getInfoData() { - String[] data = super.getInfoData(); - ArrayList mInfo = new ArrayList<>(Arrays.asList(data)); - String mode; - switch (machineMode) { - case MACHINEMODE_METAL -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.metal"); - case MACHINEMODE_FLUID -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.fluid"); - default -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.misc"); - } - mInfo.add(mode); - return mInfo.toArray(new String[0]); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mInternalMode")) { - machineMode = aNBT.getInteger("mInternalMode"); - } - super.loadNBTData(aNBT); - } - - @Override - public boolean isInputSeparationEnabled() { - return true; - } - - @Override - protected CheckRecipeResult doCheckRecipe() { - - if (machineMode != MACHINEMODE_MISC || !isInputSeparationEnabled()) { - return super.doCheckRecipe(); - } else { - CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE; - - // check crafting input hatches first - if (supportsCraftingMEBuffer()) { - for (IDualInputHatch dualInputHatch : mDualInputHatches) { - for (var it = dualInputHatch.inventories(); it.hasNext();) { - IDualInputInventory slot = it.next(); - processingLogic.setInputItems(slot.getItemInputs()); - processingLogic.setInputFluids(slot.getFluidInputs()); - CheckRecipeResult foundResult = processingLogic.process(); - if (foundResult.wasSuccessful()) { - return foundResult; - } - if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { - // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; - } - } - } - } - - // Logic for GT_MetaTileEntity_Hatch_Solidifier - for (GT_MetaTileEntity_Hatch_Input solidifierHatch : mInputHatches) { - if (solidifierHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) { - ItemStack mold = ((GT_MetaTileEntity_Hatch_Solidifier) solidifierHatch).getMold(); - FluidStack fluid = solidifierHatch.getFluid(); - - if (mold != null && fluid != null) { - List inputItems = new ArrayList<>(); - inputItems.add(mold); - inputItems.add(GT_Utility.getIntegratedCircuit(22)); - - processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); - processingLogic.setInputFluids(fluid); - - CheckRecipeResult foundResult = processingLogic.process(); - if (foundResult.wasSuccessful()) { - return foundResult; - } - if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { - // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; - } - } - } - } - processingLogic.clear(); - processingLogic.setInputFluids(getStoredFluids()); - // Default logic - for (GT_MetaTileEntity_Hatch_InputBus bus : mInputBusses) { - if (bus instanceof GT_MetaTileEntity_Hatch_CraftingInput_ME) { - continue; - } - List inputItems = new ArrayList<>(); - for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stored = bus.getStackInSlot(i); - if (stored != null) { - inputItems.add(stored); - } - } - if (canUseControllerSlotForRecipe() && getControllerSlot() != null) { - inputItems.add(getControllerSlot()); - } - processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); - CheckRecipeResult foundResult = processingLogic.process(); - if (foundResult.wasSuccessful()) { - return foundResult; - } - if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { - // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; - } - } - - return result; - } - } - - @Override - public ArrayList getStoredFluids() { - ArrayList rList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { - if (tHatch instanceof GT_MetaTileEntity_Hatch_Solidifier) { - continue; - } - - setHatchRecipeMap(tHatch); - if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { - for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { - if (tFluid != null) { - rList.add(tFluid); - } - } - } else if (tHatch instanceof GT_MetaTileEntity_Hatch_Input_ME) { - if (tHatch.isValid()) { - for (FluidStack fluidStack : ((GT_MetaTileEntity_Hatch_Input_ME) tHatch).getStoredFluids()) { - if (fluidStack == null) continue; - rList.add(fluidStack); - } - } - } else { - if (tHatch.getFillableStack() != null) { - rList.add(tHatch.getFillableStack()); - } - } - } - - return rList; - } - - @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); - tag.setInteger("mode", machineMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - if (tag.hasKey("mode")) { - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector - .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_MULTI_MACHINE.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); - } - - @Override - public int nextMachineMode() { - mLastRecipe = null; - if (machineMode == MACHINEMODE_METAL) return MACHINEMODE_FLUID; - else if (machineMode == MACHINEMODE_FLUID) return MACHINEMODE_MISC; - else return MACHINEMODE_METAL; - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_LPF_METAL); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_LPF_FLUID); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_DEFAULT); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java deleted file mode 100644 index d7e7b2047f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java +++ /dev/null @@ -1,262 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -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 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 gregtech.api.enums.SoundResource; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialPlatePress - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - - private static final int MACHINEMODE_BENDER = 0; - private static final int MACHINEMODE_FORMER = 1; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); - } - - @Override - public String getMachineType() { - return "Bending Machine, Forming Press"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for Advanced Bending & Forming") - .addInfo("500% faster than using single block machines of the same voltage") - .addInfo("Processes four items per voltage tier") - .addInfo("Circuit for recipe goes in the Input Bus") - .addInfo("Each Input Bus can have a different Circuit/Shape!") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Material Press Machine Casings", 6, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialPlatePress.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(50) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 4)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialPlatePressActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialPlatePress; - } - - @Override - protected int getCasingTextureId() { - return 50; - } - - @Override - public RecipeMap getRecipeMap() { - return (machineMode == MACHINEMODE_FORMER) ? RecipeMaps.formingPressRecipes : RecipeMaps.benderRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.formingPressRecipes, RecipeMaps.benderRecipes); - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 6F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - if (machineMode == MACHINEMODE_FORMER) - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - // Migrates old NBT tag to the new one - if (aNBT.hasKey("mFormingMode")) { - machineMode = aNBT.getBoolean("mFormingMode") ? MACHINEMODE_FORMER : MACHINEMODE_BENDER; - } - super.loadNBTData(aNBT); - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_BENDING); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_FORMING); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_PLATE_PRESS.mode." + machineMode); - } - - @Override - public boolean isInputSeparationEnabled() { - return true; - } - - @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); - tag.setInteger("mode", machineMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector - .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_PLATE_PRESS.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java deleted file mode 100644 index 5189e546a5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java +++ /dev/null @@ -1,209 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Random; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialSifter - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialSifter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialSifter(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialSifter(this.mName); - } - - @Override - public String getMachineType() { - return "Sifter"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Sifter") - .addInfo("400% faster than single-block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 3, 5, false) - .addController("Bottom Center") - .addCasingInfoMin("Sieve Grate", 18, false) - .addCasingInfoMin("Sieve Casings", 35, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC" }, - { "CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC" }, - { "CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialSifter.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(TAE.GTPP_INDEX(21)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 5)))) - .addElement('M', ofBlock(ModBlocks.blockCasings2Misc, 6)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 2, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 2, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 2, 0) && mCasing >= 35 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialSifterActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialSifter; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(21); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.sifterRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) - && (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP) - && (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0) - && (!aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP))) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - if (tRandom.nextFloat() > 0.4) return; - - final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * 2; - final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * 2; - - aBaseMetaTileEntity.getWorld() - .spawnParticle( - "smoke", - (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), - aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), - (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), - 0.0, - 0.0, - 0.0); - } - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 5F) - .setEuModifier(0.75F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java deleted file mode 100644 index d1e9e0d6a0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java +++ /dev/null @@ -1,184 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -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 gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialThermalCentrifuge extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialThermalCentrifuge(this.mName); - } - - @Override - public String getMachineType() { - return "Thermal Centrifuge"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Thermal Centrifuge") - .addInfo("150% faster than using single block machines of the same voltage") - .addInfo("Only uses 80% of the EU/t normally required") - .addInfo("Processes eight items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 2, 3, false) - .addController("Front Center") - .addCasingInfoMin("Thermal Processing Casings/Noise Hazard Sign Blocks", 8, false) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addMufflerHatch("Bottom Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(mName, transpose(new String[][] { { "X~X", "XXX", "XXX" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialThermalCentrifuge.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), - onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 9)))) - .addElement( - 'X', - ofChain( - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), - onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 9)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 0, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 0, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 0, 0) && mCasing >= 8 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialThermalCentrifugeActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialThermalCentrifuge; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.thermalCentrifugeRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2.5F) - .setEuModifier(0.8F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(16); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java deleted file mode 100644 index a38b7f1a9e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ /dev/null @@ -1,256 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -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 java.util.ArrayList; -import java.util.Objects; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mCryoFuelName = "Gelid Cryotheum"; - public static String mCasingName = "Advanced Cryogenic Casing"; - public static String mHatchName = "Cryotheum Hatch"; - public static FluidStack mFuelStack; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private final ArrayList mCryotheumHatches = new ArrayList<>(); - - public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - } - - public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { - super(aName); - mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return (IMetaTileEntity) new GregtechMetaTileEntity_IndustrialVacuumFreezer(this.mName); - } - - @Override - public String getMachineType() { - return "Vacuum Freezer"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Vacuum Freezer") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 4") - .addInfo("Consumes 10L of " + mCryoFuelName + "/s during operation") - .addInfo("Constructed exactly the same as a normal Vacuum Freezer") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin(mCasingName, 10, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addOtherStructurePart(mHatchName, "Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) - .adder(GregtechMetaTileEntity_IndustrialVacuumFreezer::addCryotheumHatch) - .hatchId(967) - .shouldReject(t -> !t.mCryotheumHatches.isEmpty()) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_IndustrialVacuumFreezer.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 10)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mCryotheumHatches.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() && !mCryotheumHatches.isEmpty(); - } - - private boolean addCryotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase - && aMetaTileEntity.getBaseMetaTileEntity() - .getMetaTileID() == 967) { - return addToMachineListInternal(mCryotheumHatches, aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void updateSlots() { - for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : filterValidMTEs(mCryotheumHatches)) tHatch.updateSlots(); - super.updateSlots(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialVacuumFreezerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialVacuumFreezer; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.advancedFreezerRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return 4; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - /* - * if (this.getBaseMetaTileEntity().isActive()) { if (!this.depleteInput(mFuelStack.copy())) { - * this.getBaseMetaTileEntity().setActive(false); } } - */ - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (this.mStartUpCheck < 0) { - if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled()) { - if (aTick % 20 == 0 || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled()) { - if (!this.depleteInputFromRestrictedHatches(this.mCryotheumHatches, 10)) { - this.causeMaintenanceIssue(); - this.stopMachine( - ShutDownReasonRegistry - .outOfFluid(Objects.requireNonNull(FluidUtils.getFluidStack("cryotheum", 10)))); - } - } - } - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java deleted file mode 100644 index 8645bc6686..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java +++ /dev/null @@ -1,425 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -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.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.enums.TAE; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IIconContainer; -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.recipe.check.SimpleCheckRecipeResult; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_IndustrialWashPlant - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final int MACHINEMODE_OREWASH = 0; - private static final int MACHINEMODE_SIMPLEWASH = 1; - private static final int MACHINEMODE_CHEMBATH = 2; - - public GregtechMetaTileEntity_IndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialWashPlant(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWashPlant(this.mName); - } - - @Override - public String getMachineType() { - return "Ore Washer, Simple Washer, Chemical Bath"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Wash Plant") - .addInfo("Can be configured with a screwdriver to also do Simple Washer and process Chemical Bathing") - .addInfo("400% faster than using single block machines of the same voltage") - .addInfo("Processes four item per voltage tier") - .addInfo("Always requires an Input Hatch full of water to refill structure") - .addInfo("Need to be filled with water.") - .addInfo("Will automatically fill water from input hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 3, 7, true) - .addController("Front Center") - .addCasingInfoMin("Wash Plant Casings", 40, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCCCC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CCCCC" }, - { "CC~CC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CCCCC" }, - { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialWashPlant.class) - .atLeast(InputBus, InputHatch, OutputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement( - 'w', - ofChain( - isAir(), - ofBlockAnyMeta(Blocks.water), - ofBlockAnyMeta(Blocks.flowing_water), - ofBlockAnyMeta(BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 2, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 1, 0) && mCasing >= 40 && checkHatch(); - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a washer, water will flow out. - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialWashPlantActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialWashPlant; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public RecipeMap getRecipeMap() { - switch (machineMode) { - case MACHINEMODE_OREWASH -> { - return RecipeMaps.oreWasherRecipes; - } - case MACHINEMODE_SIMPLEWASH -> { - return GTPPRecipeMaps.simpleWasherRecipes; - } - default -> { - return RecipeMaps.chemicalBathRecipes; - } - } - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays - .asList(RecipeMaps.oreWasherRecipes, GTPPRecipeMaps.simpleWasherRecipes, RecipeMaps.chemicalBathRecipes); - } - - @Override - public int getRecipeCatalystPriority() { - return -10; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (checkForWater()) { - return CheckRecipeResultRegistry.SUCCESSFUL; - } - return SimpleCheckRecipeResult.ofFailure("no_water"); - } - }.setSpeedBonus(1F / 5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - if (machineMode == MACHINEMODE_CHEMBATH) - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 4; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(11); - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - if (mDirectionX == 0) { - mCurrentDirectionX = 2; - mCurrentDirectionZ = 3; - mOffsetX_Lower = -2; - mOffsetX_Upper = 2; - mOffsetZ_Lower = -3; - mOffsetZ_Upper = 3; - } else { - mCurrentDirectionX = 3; - mCurrentDirectionZ = 2; - mOffsetX_Lower = -3; - mOffsetX_Upper = 3; - mOffsetZ_Lower = -2; - mOffsetZ_Upper = 2; - } - - // if (aBaseMetaTileEntity.fac) - - final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; - final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; ++h) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == Blocks.water) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = null; - if (tBlock == Blocks.air || tBlock == Blocks.flowing_water) { - fluidUsed = Blocks.water; - } - if (tBlock == Blocks.water) { - fluidUsed = BlocksItems.getFluidBlock(InternalName.fluidDistilledWater); - } - aBaseMetaTileEntity.getWorld() - .setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, - fluidUsed); - } - } - } - } - } - if (tBlock == Blocks.water) { - ++tAmount; - // Utils.LOG_WARNING("Found Water"); - } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { - ++tAmount; - ++tAmount; - // Utils.LOG_WARNING("Found Distilled Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 45; - if (isValidWater) { - Logger.WARNING("Filled structure."); - } else { - Logger.WARNING("Did not fill structure."); - } - return isValidWater; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mChemicalMode")) { - boolean aTempMode = aNBT.getBoolean("mChemicalMode"); - if (aTempMode) { - machineMode = 2; - } else { - machineMode = 0; - } - aNBT.removeTag("mChemicalMode"); - } - if (aNBT.hasKey("mMode")) { - machineMode = aNBT.getInteger("mMode"); - } - super.loadNBTData(aNBT); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + machineMode); - } - - @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); - tag.setInteger("mode", machineMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); - } - - @Override - public int nextMachineMode() { - if (machineMode == MACHINEMODE_OREWASH) return MACHINEMODE_SIMPLEWASH; - else if (machineMode == MACHINEMODE_SIMPLEWASH) return MACHINEMODE_CHEMBATH; - else return MACHINEMODE_OREWASH; - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_WASHPLANT); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_SIMPLEWASHER); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_CHEMBATH); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java deleted file mode 100644 index 4304b5b52a..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ /dev/null @@ -1,213 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraftforge.common.util.ForgeDirection; - -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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialWireMill - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); - } - - @Override - public String getMachineType() { - return "Wiremill"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Wire Factory") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Only uses 75% of the EU/t normally required") - .addInfo("Processes four items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 5, true) - .addController("Front Center") - .addCasingInfoMin("Wire Factory Casings", 14, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialWireMill.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_RECYCLER_OP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDIndustrialWireMillActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDIndustrialWireMill; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(6); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.wiremillRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3F) - .setEuModifier(0.75F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - inputSeparation = !inputSeparation; - aPlayer.addChatMessage( - new ChatComponentTranslation( - inputSeparation ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - inputSeparation = aNBT.getBoolean("isBussesSeparate"); - } - } - - @Override - public int getMaxParallelRecipes() { - return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasingsMisc; - } - - public byte getCasingMeta() { - return 6; - } - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(6); - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java deleted file mode 100644 index c14cae9b88..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ /dev/null @@ -1,529 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -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 java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.util.ForgeDirection; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - protected boolean boostEu = false; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final IIconContainer frontFaceActive = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); - private static final IIconContainer frontFace = new CustomIcon("iconsets/Grinder/GRINDER5"); - - private final ArrayList mMillingBallBuses = new ArrayList<>(); - private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); - - public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IsaMill(String aName) { - super(aName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Grinding Machine") - .addInfo("Grind ores.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 7, false) - .addController("Front Center") - .addCasingInfoMin("IsaMill Exterior Casing", 40, false) - .addOtherStructurePart("IsaMill Gearbox", "5x, Inner Blocks") - .addOtherStructurePart("IsaMill Piping", "8x, ring around controller") - .addStructureInfo("IsaMill Pipings must not be obstructed in front (only air blocks)") - .addOtherStructurePart("Milling Ball Hatch", "Any Casing") - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC" }, - { "D~D", "CGC", "CGC", "CGC", "CGC", "CGC", "CCC" }, - { "DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) - .adder(GregtechMetaTileEntity_IsaMill::addMillingBallsHatch) - .hatchClass(GT_MetaTileEntity_Hatch_MillingBalls.class) - .shouldReject(t -> !t.mMillingBallBuses.isEmpty()) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_IsaMill.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('D', ofBlock(getIntakeBlock(), getIntakeMeta())) - .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mMillingBallBuses.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 48 - 8 && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() && mMillingBallBuses.size() == 1; - } - - @Override - protected IIconContainer getActiveOverlay() { - return frontFaceActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return frontFace; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(2); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - private boolean addMillingBallsHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { - return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { - log("Found GT_MetaTileEntity_Hatch_MillingBalls"); - return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); - } - return super.addToMachineList(aTileEntity, aBaseCasingIndex); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.millingRecipes; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mMillingBallBuses.clear(); - } - } - if (aTick % 20 == 0 && isMachineRunning()) { - checkForEntities(aBaseMetaTileEntity, aTick); - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - private final AutoMap mFrontBlockPosCache = new AutoMap<>(); - - public void checkForEntities(IGregTechTileEntity aBaseMetaTileEntity, long aTime) { - - if (aTime % 100 == 0) { - mFrontBlockPosCache.clear(); - } - if (mFrontBlockPosCache.isEmpty()) { - ForgeDirection tSide = aBaseMetaTileEntity.getBackFacing(); - int aTileX = aBaseMetaTileEntity.getXCoord(); - int aTileY = aBaseMetaTileEntity.getYCoord(); - int aTileZ = aBaseMetaTileEntity.getZCoord(); - boolean xFacing = tSide.offsetX != 0; - boolean zFacing = tSide.offsetZ != 0; - - // Check Casings - int aDepthOffset = (tSide == ForgeDirection.NORTH || tSide == ForgeDirection.WEST) ? 1 : -1; - for (int aHorizontalOffset = -1; aHorizontalOffset < 2; aHorizontalOffset++) { - for (int aVerticalOffset = -1; aVerticalOffset < 2; aVerticalOffset++) { - int aX = !xFacing ? (aTileX + aHorizontalOffset) : (aTileX + aDepthOffset); - int aY = aTileY + aVerticalOffset; - int aZ = !zFacing ? (aTileZ + aHorizontalOffset) : (aTileZ + aDepthOffset); - mFrontBlockPosCache.add(new BlockPos(aX, aY, aZ, aBaseMetaTileEntity.getWorld())); - } - } - } - - AutoMap aEntities = getEntities(mFrontBlockPosCache, aBaseMetaTileEntity.getWorld()); - if (!aEntities.isEmpty()) { - for (EntityLivingBase aFoundEntity : aEntities) { - if (aFoundEntity instanceof EntityPlayer aPlayer) { - if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { - continue; - } else { - if (aFoundEntity.getHealth() > 0) { - EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, getPlayerDamageValue(aPlayer, 10)); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - generateParticles(aFoundEntity); - } - } - } - } else if (aFoundEntity.getHealth() > 0) { - EntityUtils.doDamage( - aFoundEntity, - mIsaMillDamageSource, - Math.max(1, (int) (aFoundEntity.getMaxHealth() / 3))); - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - generateParticles(aFoundEntity); - } - } - } - } - } - - // 20 armor points add 80% damage reduction, more points add more damage reduction - private int getPlayerDamageValue(EntityPlayer player, int damage) { - int armorValue = player.getTotalArmorValue(); - int reducedDamage = (int) (damage - damage * (armorValue * 0.04)); - return Math.max(reducedDamage, 0); - } - - private static AutoMap getEntities(AutoMap aPositionsToCheck, World aWorld) { - AutoMap aEntities = new AutoMap<>(); - HashSet aChunksToCheck = new HashSet<>(); - if (!aPositionsToCheck.isEmpty()) { - Chunk aLocalChunk; - for (BlockPos aPos : aPositionsToCheck) { - aLocalChunk = aWorld.getChunkFromBlockCoords(aPos.xPos, aPos.zPos); - aChunksToCheck.add(aLocalChunk); - } - } - if (!aChunksToCheck.isEmpty()) { - AutoMap aEntitiesFound = new AutoMap<>(); - for (Chunk aChunk : aChunksToCheck) { - if (aChunk.isChunkLoaded) { - List[] aEntityLists = aChunk.entityLists; - for (List aEntitySubList : aEntityLists) { - for (Object aEntity : aEntitySubList) { - if (aEntity instanceof EntityLivingBase aPlayer) { - aEntitiesFound.add(aPlayer); - } - } - } - } - } - if (!aEntitiesFound.isEmpty()) { - for (EntityLivingBase aEntity : aEntitiesFound) { - BlockPos aPlayerPos = EntityUtils.findBlockPosOfEntity(aEntity); - for (BlockPos aBlockSpaceToCheck : aPositionsToCheck) { - if (aBlockSpaceToCheck.equals(aPlayerPos)) { - aEntities.add(aEntity); - } - } - } - } - } - return aEntities; - } - - private static void generateParticles(EntityLivingBase aEntity) { - BlockPos aPlayerPosBottom = EntityUtils.findBlockPosOfEntity(aEntity); - BlockPos aPlayerPosTop = aPlayerPosBottom.getUp(); - AutoMap aEntityPositions = new AutoMap<>(); - aEntityPositions.add(aPlayerPosBottom); - aEntityPositions.add(aPlayerPosTop); - for (int i = 0; i < 64; i++) { - BlockPos aEffectPos = aEntityPositions.get(aEntity.height > 1f ? MathUtils.randInt(0, 1) : 0); - float aOffsetX = MathUtils.randFloat(-0.35f, 0.35f); - float aOffsetY = MathUtils.randFloat(-0.25f, 0.35f); - float aOffsetZ = MathUtils.randFloat(-0.35f, 0.35f); - aEntity.worldObj.spawnParticle( - "reddust", - aEffectPos.xPos + aOffsetX, - aEffectPos.yPos + 0.3f + aOffsetY, - aEffectPos.zPos + aOffsetZ, - 0.0D, - 0.0D, - 0.0D); - } - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public Block getIntakeBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getIntakeMeta() { - return 1; - } - - public Block getGearboxBlock() { - return ModBlocks.blockCasings5Misc; - } - - public byte getGearboxMeta() { - return 2; - } - - public byte getCasingTextureIndex() { - return 66; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IsaMill(this.mName); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIsaMill; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public String[] getExtraInfoData() { - return new String[] { "IsaMill Grinding Machine", "Current Efficiency: " + (mEfficiency / 100) + "%", - getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String getMachineType() { - return "Grinding Machine"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - /* - * Milling Ball Handling - */ - - @Override - public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); - for (GT_MetaTileEntity_Hatch_MillingBalls tHatch : filterValidMTEs(mMillingBallBuses)) { - AutoMap aHatchContent = tHatch.getContentUsageSlots(); - if (!aHatchContent.isEmpty()) { - tItems.addAll(aHatchContent); - } - } - return tItems; - } - - public int getMaxBallDurability(ItemStack aStack) { - return ItemGenericChemBase.getMaxBallDurability(aStack); - } - - private ItemStack findMillingBall(ItemStack[] aItemInputs) { - if (mMillingBallBuses.size() != 1) { - return null; - } else { - GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); - if (aBus != null) { - AutoMap aAvailableItems = aBus.getContentUsageSlots(); - if (!aAvailableItems.isEmpty()) { - for (final ItemStack aInput : aItemInputs) { - if (ItemUtils.isMillingBall(aInput)) { - for (ItemStack aBall : aAvailableItems) { - if (GT_Utility.areStacksEqual(aBall, aInput, true)) { - Logger.INFO("Found a valid milling ball to use."); - return aBall; - } - } - } - } - } - } - } - return null; - } - - private void damageMillingBall(ItemStack aStack) { - if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * 1))) { - int damage = getMillingBallDamage(aStack) + 1; - log("damage milling ball " + damage); - if (damage >= getMaxBallDurability(aStack)) { - log("consuming milling ball"); - aStack.stackSize -= 1; - } else { - setDamage(aStack, damage); - } - } else { - log("not damaging milling ball"); - } - } - - private int getMillingBallDamage(ItemStack aStack) { - return ItemGenericChemBase.getMillingBallDamage(aStack); - } - - private void setDamage(ItemStack aStack, int aAmount) { - ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - ItemStack millingBall; - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - millingBall = findMillingBall(inputItems); - if (millingBall == null) { - return SimpleCheckRecipeResult.ofFailure("no_milling_ball"); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @NotNull - @Override - public CheckRecipeResult process() { - CheckRecipeResult result = super.process(); - if (result.wasSuccessful()) { - damageMillingBall(millingBall); - } - return result; - } - }.enablePerfectOverclock(); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java deleted file mode 100644 index 6d1593bec9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java +++ /dev/null @@ -1,224 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.item.ItemStack; - -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 gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GregtechMetaTileEntity_NuclearSaltProcessingPlant extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected GT_Recipe lastRecipeToBuffer; - private int casing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_NuclearSaltProcessingPlant(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_NuclearSaltProcessingPlant(String mName) { - super(mName); - } - - @Override - public String getMachineType() { - return "Reactor Processing Unit, Cold Trap"; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity tileEntity) { - return new GregtechMetaTileEntity_NuclearSaltProcessingPlant(this.mName); - } - - @Override - public int getMaxEfficiency(ItemStack itemStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Nuclear Salt Processing Plant") - .addInfo("Processes depleted nuclear salts that come from the LFTR") - .addInfo("Handles the recipes of the Reactor Processor Unit and Cold Trap") - .addInfo("Only Thermally Insulated Casings can be replaced with hatches") - .addInfo("Mufflers on top, Energy Hatches on bottom, exactly 2 of each are required") - .addInfo("Maintenance Hatch goes on the back, opposite of the controller block") - .addInfo("Inputs go on the left side of the multi, outputs on the right side") - .addInfo("150% faster than using single block machines of the same voltage") - .addInfo("Processes two items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("IV Machine Casing", 58, false) - .addCasingInfoMin("Thermally Insulated Casing", 1, false) - .addInputBus("Left Half", 2) - .addInputHatch("Left Half", 2) - .addOutputBus("Right Half", 3) - .addOutputHatch("Right Half", 3) - .addMufflerHatch("Top Side, 2 Required", 4) - .addEnergyHatch("Bottom Side, 2 Required", 5) - .addMaintenanceHatch("Back Side, Opposite of Controller", 6) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 10); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "AAA AAA", "ADA ADA", "AAA AAA" }, - { "ABBA ACCA", "B AAA C", "ABBA ACCA" }, { "ABBB~CCCA", "B C", "ABBBFCCCA" }, - { "ABBA ACCA", "B AAA C", "ABBA ACCA" }, { "AAA AAA", "AEA AEA", "AAA AAA" } })) - .addElement('A', ofBlock(GregTech_API.sBlockCasings1, 5)) - .addElement( - 'B', - buildHatchAdder(GregtechMetaTileEntity_NuclearSaltProcessingPlant.class) - .atLeast(InputBus, InputHatch) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(2) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_NuclearSaltProcessingPlant.class) - .atLeast(OutputBus, OutputHatch) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(3) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) - .addElement( - 'D', - buildHatchAdder(GregtechMetaTileEntity_NuclearSaltProcessingPlant.class).atLeast(Muffler) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(4) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) - .addElement( - 'E', - buildHatchAdder(GregtechMetaTileEntity_NuclearSaltProcessingPlant.class).atLeast(Energy) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(5) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) - .addElement( - 'F', - buildHatchAdder(GregtechMetaTileEntity_NuclearSaltProcessingPlant.class).atLeast(Maintenance) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(6) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack itemStack, boolean hintsOnly) { - buildPiece(mName, itemStack, hintsOnly, 4, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, itemStack, 4, 2, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity baseMetaTileEntity, ItemStack itemStack) { - casing = 0; - return checkPiece(mName, 4, 2, 0) && checkHatch(); - } - - @Override - public boolean checkHatch() { - return mEnergyHatches.size() == 2 && mMufflerHatches.size() == 2 && super.checkHatch(); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.nuclearSaltProcessingPlantRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2.5F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); - } - - @Override - public String[] getExtraInfoData() { - final String running = (this.mMaxProgresstime > 0 ? "Salt Plant running" : "Salt Plant stopped"); - final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" - : "Needs Maintenance"); - String tSpecialText; - - if (lastRecipeToBuffer != null && lastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { - tSpecialText = "Currently processing: " + lastRecipeToBuffer.mOutputs[0].getDisplayName(); - } else { - tSpecialText = "Currently processing: Nothing"; - } - - return new String[] { "Nuclear Salt Processing Plant", running, maintenance, tSpecialText }; - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java deleted file mode 100644 index 19873c9dca..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java +++ /dev/null @@ -1,507 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -import java.util.ArrayList; -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.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.interfaces.IHatchElement; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.fluid.IFluidStore; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.GasSpargingRecipe; -import gregtech.api.util.GasSpargingRecipeMap; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - protected static final String STRUCTURE_PIECE_BASE = "base"; - protected static final String STRUCTURE_PIECE_LAYER = "layer"; - protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; - protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; - private static final IStructureDefinition STRUCTURE_DEFINITION; - - static { - IHatchElement layeredOutputHatch = OutputHatch - .withCount(GregtechMetaTileEntity_SpargeTower::getCurrentLayerOutputHatchCount) - .withAdder(GregtechMetaTileEntity_SpargeTower::addLayerOutputHatch); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" }, })) - .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "lll", "lcl", "lll" } })) - .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] { { "lll", "l-l", "lll" } })) - .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] { { "lll", "lll", "lll" } })) - .addElement( - 'b', - buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class) - .atLeast(Energy, InputHatch, InputBus, Maintenance) - .disallowOnly(ForgeDirection.UP) - .casingIndex(getCasingIndex()) - .dot(1) - .buildAndChain( - onElementPass( - GregtechMetaTileEntity_SpargeTower::onCasingFound, - ofBlock(ModBlocks.blockCasings5Misc, 4)))) - .addElement( - 'l', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_SpargeTower.class).atLeast(layeredOutputHatch) - .disallowOnly(ForgeDirection.UP, ForgeDirection.DOWN) - .casingIndex(getCasingIndex()) - .dot(2) - .build(), - ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addEnergyInputToMachineList, getCasingIndex(), 2), - ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 2), - onElementPass( - GregtechMetaTileEntity_SpargeTower::onCasingFound, - ofBlock(ModBlocks.blockCasings5Misc, 4)))) - .addElement( - 'c', - ofChain( - onElementPass( - t -> t.onTopLayerFound(false), - ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addOutputToMachineList, getCasingIndex(), 3)), - onElementPass( - t -> t.onTopLayerFound(false), - ofHatchAdder( - GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, - getCasingIndex(), - 3)), - onElementPass(t -> t.onTopLayerFound(true), ofBlock(ModBlocks.blockCasings5Misc, 4)), - isAir())) - .build(); - } - - protected final List> mOutputHatchesByLayer = new ArrayList<>(); - protected int mHeight; - protected int mCasing; - protected boolean mTopLayerFound; - - public GregtechMetaTileEntity_SpargeTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_SpargeTower(String aName) { - super(aName); - } - - public static int getCasingIndex() { - return 68; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SpargeTower(this.mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Gas Sparge Tower") - .addInfo("Controller block for the Sparging Tower") - .addInfo("Runs gases through depleted molten salts to extract precious fluids") - .addInfo("Works the same way as the Distillation Tower, but with a fixed height of 8") - .addInfo("Fluids are only put out at the correct height") - .addInfo("The correct height equals the slot number in the NEI recipe") - .addSeparator() - .beginStructureBlock(3, 8, 3, true) - .addController("Front bottom") - .addOtherStructurePart("Sparge Tower Exterior Casing", "45 (minimum)") - .addEnergyHatch("Any casing", 1, 2) - .addMaintenanceHatch("Any casing", 1, 2, 3) - .addInputHatch("2x Input Hatches (Any bottom layer casing)", 1) - .addOutputHatch("6x Output Hatches (At least one per layer except bottom layer)", 2, 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCASpargeTowerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCASpargeTower; - } - - @Override - protected int getCasingTextureId() { - return getCasingIndex(); - } - - @Override - public RecipeMap getRecipeMap() { - if (GTPPRecipeMaps.spargeTowerFakeRecipes.getAllRecipes() - .isEmpty()) { - generateRecipes(); - } - return GTPPRecipeMaps.spargeTowerFakeRecipes; - } - - private static boolean generateRecipes() { - for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { - GT_Recipe newRecipe = new GT_Recipe( - false, - new ItemStack[] {}, - new ItemStack[] {}, - null, - null, - aRecipe.mFluidInputs.clone(), - new FluidStack[] {}, - aRecipe.mDuration, - aRecipe.mEUt, - 0); - GTPPRecipeMaps.spargeTowerFakeRecipes.add(newRecipe); - } - return !GTPPRecipeMaps.spargeTowerFakeRecipes.getAllRecipes() - .isEmpty(); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - ArrayList tFluidList = getStoredFluids(); - long tVoltage = GT_Utility.roundUpVoltage(this.getMaxInputVoltage()); - byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - if (tFluids.length > 0) { - GT_Recipe tRecipe = getRecipeMap() - .findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids); - if (tRecipe != null) { - FluidStack[] possibleOutputs = getPossibleByproductsOfSparge( - tRecipe.mFluidInputs[0], - tRecipe.mFluidInputs[1]).toArray(new FluidStack[0]); - if (canOutputAll(possibleOutputs) && tRecipe.isRecipeInputEqual(true, tFluids)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - calculateOverclockedNessMulti((long) tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - mMaxProgresstime = Math.max(1, mMaxProgresstime); - ArrayList aFluidOutputs = getByproductsOfSparge( - tRecipe.mFluidInputs[0], - tRecipe.mFluidInputs[1]); - this.mOutputFluids = aFluidOutputs.toArray(new FluidStack[0]); - updateSlots(); - - if (lEUt > 0) { - lEUt = (-lEUt); - } - - return CheckRecipeResultRegistry.SUCCESSFUL; - } - } - } - this.lEUt = 0; - this.mEfficiency = 0; - return CheckRecipeResultRegistry.NO_RECIPE; - } - - private static List getPossibleByproductsOfSparge(final FluidStack aSpargeGas, - final FluidStack aSpentFuel) { - GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); - ArrayList aOutputGases = new ArrayList<>(); - if (aSpargeRecipe == null) { - return aOutputGases; - } - - aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); - ArrayList aTempMap = new ArrayList<>(); - for (int i = 2; i < aSpargeRecipe.mFluidOutputs.length; i++) { - int aGasAmount = aSpargeRecipe.mMaxOutputQuantity[i - 2] / 100; - FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); - FluidStack aSpargeOutput = null; - if (aGasAmount > 0) { - aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); - } - aTempMap.add(aSpargeOutput); - } - aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeRecipe.mInputGas.amount)); - aOutputGases.addAll(aTempMap); - return aOutputGases; - } - - private static ArrayList getByproductsOfSparge(final FluidStack aSpargeGas, - final FluidStack aSpentFuel) { - GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); - ArrayList aOutputGases = new ArrayList<>(); - if (aSpargeRecipe == null) { - Logger.INFO("Did not find sparge recipe!"); - return aOutputGases; - } - int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; - - aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); - ArrayList aTempMap = new ArrayList<>(); - for (int i = 2; i < aSpargeRecipe.mFluidOutputs.length; i++) { - int aGasAmount = MathUtils.randInt(0, (aSpargeRecipe.mMaxOutputQuantity[i - 2] / 100)); - FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); - aSpargeGasAmount -= aGasAmount; - FluidStack aSpargeOutput = null; - if (aGasAmount > 0) { - aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); - } - aTempMap.add(aSpargeOutput); - } - Logger.INFO("Sparge gas left: " + aSpargeGasAmount); - if (aSpargeGasAmount > 0) { - aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); - } - // Logger.INFO("Sparge Outputs: "+ItemUtils.getArrayStackNames(aTempMap)); - aOutputGases.addAll(aTempMap); - Logger.INFO("Sparge output size: " + aOutputGases.size()); - // Logger.INFO("Output of sparging: "+ItemUtils.getArrayStackNames(aOutputGases)); - return aOutputGases; - } - - protected void onCasingFound() { - mCasing++; - } - - protected void onTopLayerFound(boolean aIsCasing) { - mTopLayerFound = true; - if (aIsCasing) { - onCasingFound(); - } - } - - protected int getCurrentLayerOutputHatchCount() { - return mOutputHatchesByLayer.size() < mHeight || mHeight <= 0 ? 0 - : mOutputHatchesByLayer.get(mHeight - 1) - .size(); - } - - protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null || aTileEntity.isDead() - || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output tHatch)) { - Logger.INFO("Bad Output Hatch"); - return false; - } - while (mOutputHatchesByLayer.size() < mHeight) { - mOutputHatchesByLayer.add(new ArrayList<>()); - } - tHatch.updateTexture(aBaseCasingIndex); - boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1) - .add(tHatch); - Logger.INFO("Added Hatch: " + addedHatch); - return addedHatch; - } - - @Override - public List getFluidOutputSlots(FluidStack[] toOutput) { - return getFluidOutputSlotsByLayer(toOutput, mOutputHatchesByLayer); - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - // reset - mOutputHatchesByLayer.forEach(List::clear); - mHeight = 1; - mTopLayerFound = false; - mCasing = 0; - - // check base - if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) { - Logger.INFO("Bad Base. Height: " + mHeight); - return false; - } - - // check each layer - while (mHeight < 8 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { - if (mOutputHatchesByLayer.get(mHeight - 1) - .isEmpty()) { - // layer without output hatch - Logger.INFO("Height: " + mHeight + " - Missing output on " + (mHeight - 1)); - return false; - } - // not top - mHeight++; - } - - // validate final invariants... - Logger.INFO("Height: " + mHeight); - Logger.INFO("Casings: " + mCasing); - Logger.INFO("Required: " + (7 * mHeight - 5)); - Logger.INFO("Found Top: " + mTopLayerFound); - return mCasing >= 45 && mTopLayerFound && mMaintenanceHatches.size() == 1; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { - FluidStack tStack = mOutputFluids2[i] != null ? mOutputFluids2[i].copy() : null; - if (tStack == null) { - continue; - } - if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) { - dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); - } - } - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); - } - buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - mHeight = 0; - int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, env, false, true); - if (built >= 0) return built; - int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - mHeight = i; - built = survivialBuildPiece( - STRUCTURE_PIECE_LAYER_HINT, - stackSize, - 1, - i, - 0, - elementBudget, - env, - false, - true); - if (built >= 0) return built; - } - mHeight = tTotalHeight - 1; - return survivialBuildPiece( - STRUCTURE_PIECE_TOP_HINT, - stackSize, - 1, - tTotalHeight - 1, - 0, - elementBudget, - env, - false, - true); - } - - @Override - public String getMachineType() { - return "Gas Sparger"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public boolean onPlungerRightClick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { - int aLayerIndex = 0; - PlayerUtils - .messagePlayer(aPlayer, "Trying to clear " + mOutputHatchesByLayer.size() + " layers of output hatches."); - for (List layer : this.mOutputHatchesByLayer) { - int aHatchIndex = 0; - for (GT_MetaTileEntity_Hatch_Output hatch : layer) { - if (hatch.mFluid != null) { - PlayerUtils.messagePlayer( - aPlayer, - "Clearing " + hatch.mFluid.amount - + "L of " - + hatch.mFluid.getLocalizedName() - + " from hatch " - + aHatchIndex - + " on layer " - + aLayerIndex - + "."); - hatch.mFluid = null; - } - aHatchIndex++; - } - aLayerIndex++; - } - return aLayerIndex > 0; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - // Ensure that lEUt is negative from loaded NBT data, since this multi consumes EU - if (lEUt > 0) { - lEUt = (-lEUt); - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialAlloySmelter.java new file mode 100644 index 0000000000..ed14343fa3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialAlloySmelter.java @@ -0,0 +1,221 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +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.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTEIndustrialAlloySmelter extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + private HeatingCoilLevel mHeatingCapacity; + private int mLevel = 0; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialAlloySmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + public MTEIndustrialAlloySmelter(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEIndustrialAlloySmelter(this.mName); + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.alloySmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String getMachineType() { + return "Alloy Smelter"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Alloy Smelter") + .addInfo("Gains one parallel per voltage tier") + .addInfo("Gains one multiplier per coil tier") + .addInfo("Parallel = Tier * Coil Tier") + .addInfo("Gains 5% speed bonus per coil tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, true) + .addController("Bottom center") + .addCasingInfoMin("Inconel Reinforced Casings", 8, false) + .addOtherStructurePart("Integral Encasement V", "Middle Layer") + .addOtherStructurePart("Heating Coils", "Above and below Integral Encasements") + .addInputBus("Any Inconel Reinforced Casing", 1) + .addOutputBus("Any Inconel Reinforced Casing", 1) + .addEnergyHatch("Any Inconel Reinforced Casing", 1) + .addMaintenanceHatch("Any Inconel Reinforced Casing", 1) + .addMufflerHatch("Any Inconel Reinforced Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "VVV", "V-V", "VVV" }, + { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialAlloySmelter.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) + .addElement( + 'H', + ofCoil(MTEIndustrialAlloySmelter::setCoilLevel, MTEIndustrialAlloySmelter::getCoilLevel)) + .addElement('V', ofBlock(ModBlocks.blockCasingsTieredGTPP, 4)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) && mCasing >= 8 + && getCoilLevel() != HeatingCoilLevel.None + && (mLevel = getCoilLevel().getTier() + 1) > 0 + && checkHatch(); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mLevel * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setSpeedBoost(100F / (100F + 5F * mLevel)) + .setHeatOC(true) + .setRecipeHeat(0) + // Need to multiply by 2 because heat OC is done only once every 1800 and this one does it once + // every + // 900 + .setMachineHeat((int) (getCoilLevel().getHeat() * 2)); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } + + @Override + public boolean isInputSeparationEnabled() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialArcFurnace.java new file mode 100644 index 0000000000..256e1219aa --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialArcFurnace.java @@ -0,0 +1,359 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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 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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialArcFurnace extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + // 862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 3); + public static String mCasingName = "Tempered Arc Furnace Casing"; + private boolean mPlasmaMode = false; + + private int mSize = 0; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialArcFurnace(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialArcFurnace(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialArcFurnace(this.mName); + } + + @Override + public String getMachineType() { + return "(Plasma/Electric) Arc Furnace"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Industrial Arc Furnace") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes 8 * voltage tier * W items") + .addInfo("Right-click controller with a Screwdriver to change modes") + .addInfo("Max Size required to process Plasma recipes") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Top center") + .addStructureInfo("Size: nxnx3 [WxHxL] (Hollow)") + .addStructureInfo("n can be 3, 5 or 7") + .addCasingInfoMin(mCasingName, 10, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + /** + * The front part of multi. Used to determine the tier, or in other words, determine the size of multi. + */ + private static final String STRUCTURE_PIECE_FRONT = "front"; + /** + * The rest part of multi. + */ + private static final String STRUCTURE_PIECE_REST = "rest"; + private static final int MAX_TIER = 3; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_FRONT + 1, new String[][] { { "CCC", "C~C", "CCC" } }) + .addShape(STRUCTURE_PIECE_FRONT + 2, new String[][] { { "CCCCC", "C C", "C C", "C C", "CCCCC" } }) + .addShape( + STRUCTURE_PIECE_FRONT + 3, + new String[][] { { "CCCCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCCCC" }, }) + .addShape(STRUCTURE_PIECE_REST + 1, new String[][] { { "CCC", "C-C", "CCC" }, { "CCC", "CCC", "CCC" } }) + .addShape( + STRUCTURE_PIECE_REST + 2, + new String[][] { { "CCCCC", "C---C", "C---C", "C---C", "CCCCC" }, + { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" } }) + .addShape( + STRUCTURE_PIECE_REST + 3, + new String[][] { { "CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC" }, + { "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC" }, }) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialArcFurnace.class) + .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .allowOnly(ForgeDirection.NORTH) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 3)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + private int getTierFromHint(ItemStack stackSize) { + if (stackSize.stackSize <= 0 || stackSize.stackSize >= MAX_TIER) { + return MAX_TIER; + } + return stackSize.stackSize; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int maxTier = getTierFromHint(stackSize); + for (int tier = 1; tier <= maxTier; tier++) { + buildPiece(STRUCTURE_PIECE_FRONT + tier, stackSize, hintsOnly, tier, tier, 0); + } + buildPiece(STRUCTURE_PIECE_REST + maxTier, stackSize, hintsOnly, maxTier, maxTier, -1); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + int maxTier = getTierFromHint(stackSize); + int built; + for (int tier = 1; tier <= maxTier; tier++) { + built = survivialBuildPiece( + STRUCTURE_PIECE_FRONT + tier, + stackSize, + tier, + tier, + 0, + elementBudget, + env, + false, + true); + if (built >= 0) return built; + } + + return survivialBuildPiece( + STRUCTURE_PIECE_REST + maxTier, + stackSize, + maxTier, + maxTier, + -1, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mSize = 0; + int tier = 0; + while (tier < MAX_TIER && checkPiece(STRUCTURE_PIECE_FRONT + (tier + 1), (tier + 1), (tier + 1), 0)) { + tier++; + } + if (tier <= 0) return false; + if (checkPiece(STRUCTURE_PIECE_REST + tier, tier, tier, -1)) { + mSize = 2 * tier + 1; + return mCasing >= 10 && checkHatch(); + } + return false; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialArcFurnaceActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialArcFurnace; + } + + @Override + protected int getCasingTextureId() { + return mCasingTextureID; + } + + @Override + public RecipeMap getRecipeMap() { + return mPlasmaMode ? RecipeMaps.plasmaArcFurnaceRecipes : RecipeMaps.arcFurnaceRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.arcFurnaceRecipes, RecipeMaps.plasmaArcFurnaceRecipes); + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mSize * 8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public byte getCasingMeta() { + return 3; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mSize > 5) { + this.mPlasmaMode = !mPlasmaMode; + if (mPlasmaMode) { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + + "MODE" + + EnumChatFormatting.RESET + + "] " + + EnumChatFormatting.LIGHT_PURPLE + + "Plasma" + + EnumChatFormatting.RESET); + } else { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + + "MODE" + + EnumChatFormatting.RESET + + "] " + + EnumChatFormatting.YELLOW + + "Electric" + + EnumChatFormatting.RESET); + } + } else { + PlayerUtils.messagePlayer( + aPlayer, + "[" + EnumChatFormatting.RED + + "MODE" + + EnumChatFormatting.RESET + + "] " + + EnumChatFormatting.GRAY + + "Cannot change mode, structure not large enough." + + EnumChatFormatting.RESET); + } + mLastRecipe = null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mPlasmaMode", mPlasmaMode); + aNBT.setInteger("mSize", mSize); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mPlasmaMode = aNBT.getBoolean("mPlasmaMode"); + mSize = aNBT.getInteger("mSize"); + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + super.getWailaNBTData(player, tile, tag, world, x, y, z); + tag.setBoolean("mode", mPlasmaMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_ARC_FURNACE.mode." + (tag.getBoolean("mode") ? 1 : 0)) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java new file mode 100644 index 0000000000..86a971cb5c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java @@ -0,0 +1,228 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTEIndustrialCentrifuge extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private boolean mIsAnimated; + private static final CustomIcon frontFaceActive = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static final CustomIcon frontFace = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + // public static double recipesComplete = 0; + + public MTEIndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mIsAnimated = true; + } + + public MTEIndustrialCentrifuge(final String aName) { + super(aName); + mIsAnimated = true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Centrifuge"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Centrifuge") + .addInfo("125% faster than using single block machines of the same voltage") + .addInfo("Disable animations with a screwdriver") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes six items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Centrifuge Casings", 6, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialCentrifuge.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 0)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + if (usingAnimations()) { + return frontFaceActive; + } else { + return frontFace; + } + } + + @Override + protected IIconContainer getInactiveOverlay() { + return frontFace; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(0); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.centrifugeNonCellRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setEuModifier(0.9F) + .setSpeedBonus(1F / 2.25F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (6 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(0); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mIsAnimated = !mIsAnimated; + Logger.INFO("Is Centrifuge animated " + this.mIsAnimated); + if (this.mIsAnimated) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture. "); + } else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture. "); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mIsAnimated", mIsAnimated); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mIsAnimated")) { + mIsAnimated = aNBT.getBoolean("mIsAnimated"); + } else { + mIsAnimated = true; + } + } + + public boolean usingAnimations() { + // Logger.INFO("Is animated? "+this.mIsAnimated); + return this.mIsAnimated; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java new file mode 100644 index 0000000000..1dc694e584 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java @@ -0,0 +1,340 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.List; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +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 gregtech.api.enums.SoundResource; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTStreamUtil; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchChiselBus; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import team.chisel.carving.Carving; + +public class MTEIndustrialChisel extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + + private ItemStack target; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + private ItemStack mInputCache; + private ItemStack mOutputCache; + private GTRecipe mCachedRecipe; + + public MTEIndustrialChisel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialChisel(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEIndustrialChisel(this.mName); + } + + @Override + public String getMachineType() { + return "Chisel"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Auto Chisel") + .addInfo("Target block goes in Controller slot for common Input Buses") + .addInfo("You can also set a target block in each Chisel Input Bus and use them as an Input Bus") + .addInfo("If no target is provided for common buses, the result of the first chisel is used") + .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfoMin("Sturdy Printer Casing", 6, false) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + // spotless:off + new String[][] { + { "CCC", "CCC", "CCC" }, + { "C~C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC" }, + })) + // spotless:on + .addElement( + 'C', + buildHatchAdder(MTEIndustrialChisel.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(90) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 5)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialChiselActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialChisel; + } + + @Override + protected int getCasingTextureId() { + return 90; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + private boolean hasValidCache(ItemStack aStack, ItemStack aSpecialSlot, boolean aClearOnFailure) { + if (mInputCache != null && mOutputCache != null && mCachedRecipe != null) { + if (GTUtility.areStacksEqual(aStack, mInputCache) && GTUtility.areStacksEqual(aSpecialSlot, mOutputCache)) { + return true; + } + } + // clear cache if it was invalid + if (aClearOnFailure) { + mInputCache = null; + mOutputCache = null; + mCachedRecipe = null; + } + return false; + } + + private void cacheItem(ItemStack aInputItem, ItemStack aOutputItem, GTRecipe aRecipe) { + mInputCache = aInputItem.copy(); + mOutputCache = aOutputItem.copy(); + mCachedRecipe = aRecipe; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean canBeMadeFrom(ItemStack from, ItemStack to) { + List results = getItemsForChiseling(from); + for (ItemStack s : results) { + if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { + return true; + } + } + return false; + } + + // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target + private static boolean hasChiselResults(ItemStack from) { + List results = getItemsForChiseling(from); + return results.size() > 0; + } + + private static List getItemsForChiseling(ItemStack aStack) { + return Carving.chisel.getItemsForChiseling(aStack); + } + + private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) { + ItemStack tOutput; + if (aTarget != null && canBeMadeFrom(aInput, aTarget)) { + tOutput = aTarget; + } else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) { + tOutput = null; + } else { + tOutput = getItemsForChiseling(aInput).get(0); + } + return tOutput; + } + + private GTRecipe generateChiselRecipe(ItemStack aInput) { + boolean tIsCached = hasValidCache(aInput, this.target, true); + if (tIsCached || aInput != null && hasChiselResults(aInput)) { + ItemStack tOutput = tIsCached ? mOutputCache.copy() : getChiselOutput(aInput, this.target); + if (tOutput != null) { + if (mCachedRecipe != null && GTUtility.areStacksEqual(aInput, mInputCache) + && GTUtility.areStacksEqual(tOutput, mOutputCache)) { + return mCachedRecipe; + } + // We can chisel this + GTRecipe aRecipe = new GTRecipe( + false, + new ItemStack[] { ItemUtils.getSimpleStack(aInput, 1) }, + new ItemStack[] { ItemUtils.getSimpleStack(tOutput, 1) }, + null, + new int[] { 10000 }, + new FluidStack[] {}, + new FluidStack[] {}, + 20, + 16, + 0); + + // Cache it + cacheItem(aInput, tOutput, aRecipe); + return aRecipe; + } + } + return null; + } + + private GTRecipe getRecipe() { + for (MTEHatchInputBus bus : this.mInputBusses) { + if (bus instanceof MTEHatchChiselBus) { // Chisel buses + if (bus.mInventory[bus.getSizeInventory() - 1] == null) continue; + this.target = bus.mInventory[bus.getSizeInventory() - 1]; + + for (int i = bus.getSizeInventory() - 2; i >= 0; i--) { + ItemStack itemsInSlot = bus.mInventory[i]; + if (itemsInSlot != null) { + GTRecipe tRecipe = generateChiselRecipe(itemsInSlot); + if (tRecipe != null) { + return tRecipe; + } + } + } + } else { + target = this.getControllerSlot(); // Common buses + for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { + ItemStack itemsInSlot = bus.mInventory[i]; + if (itemsInSlot != null) { + GTRecipe tRecipe = generateChiselRecipe(itemsInSlot); + if (tRecipe != null) { + return tRecipe; + } + } + } + } + + } + return null; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + return GTStreamUtil.ofNullable(getRecipe()); + } + }.setSpeedBonus(1F / 3F) + .setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void sendStartMultiBlockSoundLoop() { + sendLoopStart(PROCESS_START_SOUND_INDEX); + } + + @Override + public int getMaxParallelRecipes() { + return (16 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + private static ResourceLocation sChiselSound = null; + + private static ResourceLocation getChiselSound() { + if (sChiselSound == null) { + sChiselSound = new ResourceLocation(Carving.chisel.getVariationSound(Blocks.stone, 0)); + } + return sChiselSound; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + switch (aIndex) { + case PROCESS_START_SOUND_INDEX -> GTUtility + .doSoundAtClient(getChiselSound(), getTimeBetweenProcessSounds(), 1.0F, 1.0F, aX, aY, aZ); + case INTERRUPT_SOUND_INDEX -> GTUtility + .doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); + } + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialChisel; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCokeOven.java new file mode 100644 index 0000000000..552f90d855 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCokeOven.java @@ -0,0 +1,208 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialCokeOven extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mLevel = 0; + private int mCasing; + private int mCasing1; + private int mCasing2; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialCokeOven(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialCokeOven(this.mName); + } + + @Override + public String getMachineType() { + return "Coke Oven"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Processes Logs and Coal into Charcoal and Coal Coke.") + .addInfo("Controller Block for the Industrial Coke Oven") + .addInfo("Gain 4% energy discount per voltage tier") + .addInfo("Process 12x materials with Heat Resistant Casings") + .addInfo("Or 24x materials with Heat Proof Casings") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front middle at bottom") + .addCasingInfoMin("Structural Coke Oven Casings", 8, false) + .addCasingInfoMin("Heat Resistant/Proof Coke Oven Casings", 8, false) + .addInputBus("Any Structural Coke Oven Casing", 1) + .addOutputBus("Any Structural Coke Oven Casing", 1) + .addInputHatch("Any Structural Coke Oven Casing", 1) + .addOutputHatch("Any Structural Coke Oven Casing", 1) + .addEnergyHatch("Any Structural Coke Oven Casing", 1) + .addMaintenanceHatch("Any Structural Coke Oven Casing", 1) + .addMufflerHatch("Any Structural Coke Oven Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) + .addShape( + mName + "1", + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "aaa", "a-a", "aaa" }, { "C~C", "CCC", "CCC" }, })) + .addShape( + mName + "2", + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "bbb", "b-b", "bbb" }, { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialCokeOven.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(1)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 1)))) + .addElement( + 'H', + ofChain( + onElementPass(x -> ++x.mCasing1, ofBlock(ModBlocks.blockCasingsMisc, 2)), + onElementPass(x -> ++x.mCasing2, ofBlock(ModBlocks.blockCasingsMisc, 3)))) + .addElement('a', ofBlock(ModBlocks.blockCasingsMisc, 2)) + .addElement('b', ofBlock(ModBlocks.blockCasingsMisc, 3)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + if (stackSize.stackSize == 1) buildPiece(mName + "1", stackSize, hintsOnly, 1, 2, 0); + else buildPiece(mName + "2", stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + if (stackSize.stackSize == 1) + return survivialBuildPiece(mName + "1", stackSize, 1, 2, 0, elementBudget, env, false, true); + else return survivialBuildPiece(mName + "2", stackSize, 1, 2, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mCasing1 = 0; + mCasing2 = 0; + mLevel = 0; + if (checkPiece(mName, 1, 2, 0)) { + if (mCasing1 == 8) mLevel = 1; + if (mCasing2 == 8) mLevel = 2; + return mLevel > 0 && mCasing >= 8 && checkHatch(); + } + return false; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCACokeOvenActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCACokeOven; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(1); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.cokeOvenRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setEuModifier((100F - (GTUtility.getTier(getMaxInputVoltage()) * 4)) / 100F); + } + + @Override + public int getMaxParallelRecipes() { + return this.mLevel * 12; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCuttingMachine.java new file mode 100644 index 0000000000..5d80aac3f4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCuttingMachine.java @@ -0,0 +1,269 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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 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 gregtech.api.enums.TAE; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialCuttingMachine extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private static final int MACHINEMODE_CUTTER = 0; + private static final int MACHINEMODE_SLICER = 1; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialCuttingMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialCuttingMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Cutting Machine / Slicing Machine"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Cutting Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfoMin("Cutting Factory Frames", 14, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialCuttingMachine.class) + .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 13)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialCuttingMachineActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialCuttingMachine; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(29); + } + + @Override + public RecipeMap getRecipeMap() { + return (machineMode == MACHINEMODE_CUTTER) ? RecipeMaps.cutterRecipes : RecipeMaps.slicerRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.cutterRecipes, RecipeMaps.slicerRecipes); + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F) + .setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isInputSeparationEnabled() { + return true; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 13; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(29); + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_CUTTING); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_SLICING); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_CUTTING_MACHINE.mode." + machineMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + // Migrates old NBT tag to the new one + if (aNBT.hasKey("mCuttingMode")) { + machineMode = aNBT.getBoolean("mCuttingMode") ? MACHINEMODE_CUTTER : MACHINEMODE_SLICER; + } + super.loadNBTData(aNBT); + } + + @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); + tag.setInteger("mode", machineMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_CUTTING_MACHINE.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java new file mode 100644 index 0000000000..0975c5fa88 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java @@ -0,0 +1,274 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; + +import java.util.Arrays; +import java.util.Collection; +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.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialDehydrator extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private static int CASING_TEXTURE_ID; + private static String mCasingName = "Vacuum Casing"; + private HeatingCoilLevel mHeatingCapacity; + private boolean mDehydratorMode = false; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialDehydrator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + } + + public MTEIndustrialDehydrator(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEIndustrialDehydrator(mName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Vacuum Furnace") + .addInfo("Can toggle the operation temperature with a Screwdriver") + .addInfo("All Dehydrator recipes are Low Temp recipes") + .addInfo("Speed: +120% | EU Usage: 50% | Parallel: 4") + .addInfo("Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)") + .addInfo("Each 1800K over the min. Heat Capacity allows for one upgraded overclock") + .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, true) + .addController("Bottom Center") + .addCasingInfoMin(mCasingName, 5, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, + { "HHH", "H-H", "HHH" }, { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialDehydrator.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 10)))) + .addElement('H', ofCoil(MTEIndustrialDehydrator::setCoilLevel, MTEIndustrialDehydrator::getCoilLevel)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 4, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) && mCasing >= 5 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialDehydratorActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialDehydrator; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return mDehydratorMode ? GTPPRecipeMaps.chemicalDehydratorNonCellRecipes : GTPPRecipeMaps.vacuumFurnaceRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(GTPPRecipeMaps.chemicalDehydratorNonCellRecipes, GTPPRecipeMaps.vacuumFurnaceRecipes); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; + } + + @Override + public String getMachineType() { + return "Vacuum Furnace / Dehydrator"; + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setHeatOC(true) + .setHeatDiscount(true) + .setRecipeHeat(recipe.mSpecialValue) + .setMachineHeat((int) getCoilLevel().getHeat()); + } + }.setSpeedBonus(1F / 2.2F) + .setEuModifier(0.5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mDehydratorMode = !mDehydratorMode; + String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace"; + PlayerUtils.messagePlayer(aPlayer, "Mode: " + aMode); + mLastRecipe = null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mDehydratorMode", mDehydratorMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mDehydratorMode = aNBT.getBoolean("mDehydratorMode"); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } + + @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); + tag.setBoolean("mode", mDehydratorMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector + .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_DEHYDRATOR.mode." + (tag.getBoolean("mode") ? 1 : 0)) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialExtruder.java new file mode 100644 index 0000000000..0f2b573a2e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialExtruder.java @@ -0,0 +1,193 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialExtruder extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialExtruder(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialExtruder(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialExtruder(this.mName); + } + + @Override + public String getMachineType() { + return "Extruder"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Material Extruder") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Extrusion Shape for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different shape!") + .addInfo("You can use several input buses per multiblock") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfoMin("Inconel Reinforced Casings", 14, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialExtruder.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialExtruderActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialExtruder; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(33); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.extruderRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(33); + } + + @Override + public boolean isInputSeparationEnabled() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialFluidHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialFluidHeater.java new file mode 100644 index 0000000000..9c22e81024 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialFluidHeater.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialFluidHeater extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing1; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialFluidHeater(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialFluidHeater(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialFluidHeater(this.mName); + } + + @Override + public String getMachineType() { + return "Fluid Heater"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Fluid Heater") + .addInfo("120% faster than using single block machines of the same voltage") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes eight items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 6, 5, true) + .addController("Front Center") + .addCasingInfoMin("Top/Bottom layer: Multi-use Casings", 34, false) + .addCasingInfoMin("Middle layers: Thermal Containment Casing", 47, false) + .addInputBus("Bottom Layer (optional)", 1) + .addInputHatch("Bottom Layer", 1) + .addOutputBus("Top Layer (optional)", 1) + .addOutputHatch("Top Layer", 1) + .addEnergyHatch("Any Multi-use Casing", 1) + .addMaintenanceHatch("Any Multi-use Casing", 1) + .addMufflerHatch("Any Multi-use Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { " TTT ", "TTTTT", "TTTTT", "TTTTT", " TTT " }, + { " XXX ", "X---X", "X---X", "X---X", " XXX " }, + { " XXX ", "X---X", "X---X", "X---X", " XXX " }, + { " XXX ", "X---X", "X---X", "X---X", " XXX " }, + { " X~X ", "X---X", "X---X", "X---X", " XXX " }, + { " BBB ", "BBBBB", "BBBBB", "BBBBB", " BBB " }, })) + .addElement( + 'B', + buildHatchAdder(MTEIndustrialFluidHeater.class) + .atLeast(InputBus, InputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) + .addElement('X', ofBlock(getCasingBlock1(), getCasingMeta1())) + .addElement( + 'T', + buildHatchAdder(MTEIndustrialFluidHeater.class) + .atLeast(OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing1, ofBlock(getCasingBlock2(), getCasingMeta2())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 4, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 4, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing1 = 0; + boolean didBuild = checkPiece(mName, 2, 4, 0); + log("Built? " + didBuild + ", " + mCasing1); + return didBuild && mCasing1 >= 34 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAFluidHeaterActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAFluidHeater; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 1); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.fluidHeaterRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.2F) + .setEuModifier(0.9F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock1() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta1() { + return 11; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta2() { + return 2; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.getIndexFromPage(2, 2); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialForgeHammer.java new file mode 100644 index 0000000000..b809feaa6e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialForgeHammer.java @@ -0,0 +1,244 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.Railcraft; +import static gregtech.api.enums.Mods.ThaumicBases; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.ITierConverter; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("SpellCheckingInspection") +public class MTEIndustrialForgeHammer extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private int mAnvilTier = 0; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialForgeHammer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialForgeHammer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialForgeHammer(this.mName); + } + + @Override + public String getMachineType() { + return "Forge Hammer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Forge Hammer") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: Tier x Anvil Tier x 8") + .addInfo("T1 - Vanilla Anvil"); + if (Railcraft.isModLoaded()) { + tt.addInfo("T2 - Steel Anvil"); + } + if (EnderIO.isModLoaded()) { + tt.addInfo("T3 - Dark Steel Anvil"); + } + if (ThaumicBases.isModLoaded()) { + tt.addInfo("T3 - Thaumium Anvil"); + tt.addInfo("T4 - Void Metal Anvil"); + } + + tt.addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Forge Casing", 6, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addOtherStructurePart("Anvil", "In the center of 3x3x3 structure", 2) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + Map anvilTiers = new HashMap<>(); + + anvilTiers.put(Blocks.anvil, 1); + + if (Railcraft.isModLoaded()) { + anvilTiers.put(GameRegistry.findBlock(Railcraft.ID, "anvil"), 2); + } + + if (EnderIO.isModLoaded()) { + anvilTiers.put(GameRegistry.findBlock(EnderIO.ID, "blockDarkSteelAnvil"), 3); + } + + if (ThaumicBases.isModLoaded()) { + anvilTiers.put(GameRegistry.findBlock(ThaumicBases.ID, "thaumicAnvil"), 3); + anvilTiers.put(GameRegistry.findBlock(ThaumicBases.ID, "voidAnvil"), 4); + } + + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "CAC", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialForgeHammer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(TAE.getIndexFromPage(1, 11)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings5Misc, 6)))) + .addElement( + 'A', + ofBlocksTiered( + anvilTierConverter(anvilTiers), + getAllAnvilTiers(anvilTiers), + 0, + MTEIndustrialForgeHammer::setAnvilTier, + MTEIndustrialForgeHammer::getAnvilTier)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + private static List> getAllAnvilTiers(Map anvilTiers) { + return anvilTiers.entrySet() + .stream() + .map(e -> Pair.of(e.getKey(), e.getValue())) + .collect(Collectors.toList()); + } + + private static ITierConverter anvilTierConverter(Map anvilTiers) { + return (block, meta) -> block == null ? 0 : anvilTiers.getOrDefault(block, 0); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.RANDOM_ANVIL_USE; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialForgeHammerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialForgeHammer; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(1, 11); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.hammerRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1 / 2F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * getAnvilTier() * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialForgeHammer; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private void setAnvilTier(int tier) { + mAnvilTier = tier; + } + + private int getAnvilTier() { + return mAnvilTier; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMacerator.java new file mode 100644 index 0000000000..635e5889f5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMacerator.java @@ -0,0 +1,389 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +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.world.World; +import net.minecraftforge.common.util.Constants.NBT; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.tuple.Pair; + +import com.google.common.collect.ImmutableList; +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialMacerator extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int controllerTier = 1; + private int structureTier; + private int mCasing; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + + private static final int HORIZONTAL_OFF_SET = 1; + private static final int VERTICAL_OFF_SET = 5; + private static final int DEPTH_OFF_SET = 0; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static int getStructureCasingTier(Block b, int m) { + if (b == GregTechAPI.sBlockCasings4 && m == 2) return 1; + if (b == ModBlocks.blockCasingsMisc && m == 7) return 2; + return 0; + } + + public MTEIndustrialMacerator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialMacerator(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialMacerator(this.mName); + } + + @Override + public String getMachineType() { + return "Macerator/Pulverizer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller block for the Industrial Maceration Stack") + .addInfo("60% faster than using single block machines of the same voltage") + .addInfo("Maximum of n*tier parallels, LV = Tier 1, MV = Tier 2, etc.") + .addInfo("n=2 initially. n=8 after inserting Maceration Upgrade Chip.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 6, 3, true) + .addController("Bottom center") + .addCasingInfoMin("Maceration Stack Casings (After upgrade)", 26, false) + .addCasingInfoMin("Stable Titanium Casings (Before upgrade)", 26, false) + .addInputBus("Bottom casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addOutputBus("One per layer except bottom layer", 2) + .addMufflerHatch("Any casing except bottom layer", 2) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + STRUCTURE_PIECE_MAIN, + // spotless:off + transpose( + new String[][] { + {"AAA","AAA","AAA"}, + {"AAA","A A","AAA"}, + {"AAA","A A","AAA"}, + {"AAA","A A","AAA"}, + {"AAA","A A","AAA"}, + {"A~A","AAA","AAA"} })) + //spotless:on + .addElement( + 'A', + ofChain( + buildHatchAdder(MTEIndustrialMacerator.class) + .atLeast(Energy, Maintenance, InputBus, Muffler, OutputBus) + .casingIndex(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings4, 2)) + .allowOnly(ForgeDirection.NORTH) + .dot(1) + .build(), + onElementPass( + m -> m.mCasing++, + ofBlocksTiered( + MTEIndustrialMacerator::getStructureCasingTier, + ImmutableList + .of(Pair.of(GregTechAPI.sBlockCasings4, 2), Pair.of(ModBlocks.blockCasingsMisc, 7)), + -1, + (m, t) -> m.structureTier = t, + m -> m.structureTier)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece( + STRUCTURE_PIECE_MAIN, + stackSize, + hintsOnly, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return survivialBuildPiece( + STRUCTURE_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + structureTier = -1; + if (!checkPiece(STRUCTURE_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (structureTier < 1 || mCasing < 26 || !checkHatch()) return false; + updateHatchTexture(); + return structureTier >= controllerTier; + } + + protected void updateHatchTexture() { + int textureID = getCasingTextureId(); + for (MTEHatch h : mInputBusses) h.updateTexture(textureID); + for (IDualInputHatch h : mDualInputHatches) h.updateTexture(textureID); + for (MTEHatch h : mOutputBusses) h.updateTexture(textureID); + for (MTEHatch h : mMaintenanceHatches) h.updateTexture(textureID); + for (MTEHatch h : mMufflerHatches) h.updateTexture(textureID); + for (MTEHatch h : mEnergyHatches) h.updateTexture(textureID); + } + + @Override + public boolean checkHatch() { + return !mMufflerHatches.isEmpty() && !mMaintenanceHatches.isEmpty() + && !mOutputBusses.isEmpty() + && (!mInputBusses.isEmpty() || !mDualInputHatches.isEmpty()); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MACERATOR_OP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Active; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab; + } + + @Override + protected int getCasingTextureId() { + if (structureTier == 2) return TAE.GTPP_INDEX(7); + return GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings4, 2); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.maceratorRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -10; + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP) + && (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld() + .spawnParticle( + "smoke", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), + 0.0D, + 0.0D, + 0.0D); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == 0 && controllerTier == 1) { + ItemStack aGuiStack = this.getControllerSlot(); + if (GregtechItemList.Maceration_Upgrade_Chip.isStackEqual(aGuiStack, false, true)) { + controllerTier = 2; + mInventory[1] = ItemUtils.depleteStack(aGuiStack); + markDirty(); + // schedule a structure check + mUpdated = true; + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + if (controllerTier == 1 && !aPlayer.isSneaking()) { + ItemStack heldItem = aPlayer.getHeldItem(); + if (GregtechItemList.Maceration_Upgrade_Chip.isStackEqual(heldItem, false, true)) { + controllerTier = 2; + aPlayer.setCurrentItemOrArmor(0, ItemUtils.depleteStack(heldItem)); + if (getBaseMetaTileEntity().isServerSide()) { + markDirty(); + aPlayer.inventory.markDirty(); + // schedule a structure check + mUpdated = true; + } + return true; + } + } + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); + } + + @Override + public void onValueUpdate(byte aValue) { + structureTier = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) structureTier; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("mTier", (byte) controllerTier); + aNBT.setByte("structureTier", (byte) structureTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey("mTier", NBT.TAG_BYTE)) + // we assume old macerators are all T2 variants, as they were made before price reduction and shouldn't need + // to worry about upgrading + controllerTier = 2; + else controllerTier = aNBT.getByte("mTier"); + + structureTier = aNBT.getByte("structureTier"); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + super.initDefaultModes(aNBT); + if (aNBT == null || !aNBT.hasKey("mTier")) { + controllerTier = 1; + } else { + controllerTier = aNBT.getByte("mTier"); + } + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + aNBT.setByte("mTier", (byte) controllerTier); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 1.6F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + final long tVoltage = getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GTUtility.getTier(tVoltage)); + return Math.max(1, (controllerTier == 1 ? 2 : 8) * tTier); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @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); + tag.setInteger("tier", controllerTier); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + if (tag.hasKey("tier")) { + currentTip.add( + "Tier: " + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(tag.getInteger("tier")) + + EnumChatFormatting.RESET); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMixer.java new file mode 100644 index 0000000000..e733168fca --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMixer.java @@ -0,0 +1,210 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialMixer extends GTPPMultiBlockBase implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mCasingName = "Multi-Use Casing"; + public static String mCasingName2 = "Titanium Turbine Casing"; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialMixer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + } + + public MTEIndustrialMixer(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + if (aNBT.hasKey("isBussesSeparate")) { + inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + // Fallback for existing mixers + else { + inputSeparation = true; + } + } + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialMixer(this.mName); + } + + @Override + public String getMachineType() { + return "Mixer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Mixer") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes eight recipes per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, false) + .addController("Second Layer Center") + .addCasingInfoMin(mCasingName, 6, false) + .addCasingInfoMin(mCasingName2, 2, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "CCC", "CMC", "CCC" }, { "C~C", "CMC", "CCC" }, + { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialMixer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) + .addElement('M', ofBlock(GregTechAPI.sBlockCasings4, 11)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 2, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 2, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialMixerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialMixer; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.mixerNonCellRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMolecularTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMolecularTransformer.java new file mode 100644 index 0000000000..4ffd484163 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMolecularTransformer.java @@ -0,0 +1,239 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.GregTechAPI; +import gregtech.api.interfaces.IIconContainer; +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.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialMolecularTransformer extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private static final int CASING_TEXTURE_ID = 48; + private int mCasing = 0; + + public MTEIndustrialMolecularTransformer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialMolecularTransformer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialMolecularTransformer(this.mName); + } + + @Override + public String getMachineType() { + return "Molecular Transformer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Changes the structure of items to produce new ones") + .addInfo("Maximum 1x of each bus/hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 7, 7, false) + .addController("Top Center") + .addCasingInfoMin("Robust Tungstensteel Machine Casing", 40, false) + .addCasingInfoMin("Tungstensteel Coils", 16, false) + .addCasingInfoMin("Molecular Containment Casing", 52, false) + .addCasingInfoMin("High Voltage Current Capacitor", 32, false) + .addCasingInfoMin("Particle Containment Casing", 4, false) + .addCasingInfoMin("Resonance Chamber I", 5, false) + .addCasingInfoMin("Modulator I", 4, false) + .addInputBus("Any Robust Tungstensteel Machine Casing", 1) + .addOutputBus("Any Robust Tungstensteel Machine Casing", 1) + .addEnergyHatch("Any Robust Tungstensteel Machine Casing", 1) + .addMaintenanceHatch("Any Robust Tungstensteel Machine Casing", 1) + .addMufflerHatch("Any Robust Tungstensteel Machine Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + STRUCTURE_PIECE_MAIN, + (new String[][] { { " ", " ", " xxx ", " x~x ", " xxx ", " ", " " }, + { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, + { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, + { " ", " xxx ", " xyyyx ", " xyzyx ", " xyyyx ", " xxx ", " " }, + { " t ", " ttxtt ", " tyyyt ", "txyzyxt", " tyyyt ", " ttxtt ", " t " }, + { " c ", " ccecc ", " cxfxc ", "cefefec", " cxfxc ", " ccecc ", " c " }, + { " h ", " hhhhh ", " hhhhh ", "hhhhhhh", " hhhhh ", " hhhhh ", " h " }, })) + .addElement('x', ofBlock(getCasingBlock(), getCasingMeta())) + .addElement('y', ofBlock(getCasingBlock(), getCasingMeta2())) + .addElement('z', ofBlock(getCasingBlock(), getCasingMeta3())) + .addElement('e', ofBlock(getCasingBlock2(), 0)) + .addElement('f', ofBlock(getCasingBlock2(), 4)) + .addElement('c', ofBlock(getCoilBlock(), 3)) + .addElement('t', ofBlock(getCasingBlock3(), getTungstenCasingMeta())) + .addElement( + 'h', + buildHatchAdder(MTEIndustrialMolecularTransformer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock3(), getTungstenCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); + if (this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 1 || this.mEnergyHatches.size() != 1) { + return false; + } + // there are 16 slot that only allow casing, so we subtract this from the grand total required + return aDidBuild && mCasing >= 40 - 16 && checkHatch(); + } + + protected static int getCasingTextureIndex() { + return CASING_TEXTURE_ID; + } + + protected static Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + protected static Block getCasingBlock2() { + return ModBlocks.blockSpecialMultiCasings2; + } + + protected static Block getCasingBlock3() { + return GregTechAPI.sBlockCasings4; + } + + protected static Block getCoilBlock() { + return GregTechAPI.sBlockCasings5; + } + + protected static int getCasingMeta() { + return 11; + } + + protected static int getCasingMeta2() { + return 12; + } + + protected static int getCasingMeta3() { + return 13; + } + + protected static int getTungstenCasingMeta() { + return 0; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d == ForgeDirection.UP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialMolecularTransformerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialMolecularTransformer; + } + + @Override + protected int getCasingTextureId() { + return 44; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.molecularTransformerRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMultiMachine.java new file mode 100644 index 0000000000..472b1f66fd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialMultiMachine.java @@ -0,0 +1,540 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +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 net.minecraftforge.fluids.FluidStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.metatileentity.implementations.MTEHatchMultiInput; +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.GTLanguageManager; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gregtech.common.tileentities.machines.IDualInputInventory; +import gregtech.common.tileentities.machines.MTEHatchCraftingInputME; +import gregtech.common.tileentities.machines.MTEHatchInputME; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchSolidifier; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialMultiMachine extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private final static int MACHINEMODE_METAL = 0; + private final static int MACHINEMODE_FLUID = 1; + private final static int MACHINEMODE_MISC = 2; + + private static final int MODE_COMPRESSOR = 0; + private static final int MODE_LATHE = 1; + private static final int MODE_MAGNETIC = 2; + private static final int MODE_FERMENTER = 3; + private static final int MODE_FLUIDEXTRACT = 4; + private static final int MODE_EXTRACTOR = 5; + private static final int MODE_LASER = 6; + private static final int MODE_AUTOCLAVE = 7; + private static final int MODE_FLUIDSOLIDIFY = 8; + private static final int[][] MODE_MAP = new int[][] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; + public static final String[] aToolTipNames = new String[9]; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + static { + for (int id = 0; id < 9; id++) { + RecipeMap recipeMap = getRecipeMap(id); + if (recipeMap != null) { + String aNEI = GTLanguageManager.getTranslation(getRecipeMap(id).unlocalizedName); + aToolTipNames[id] = aNEI != null ? aNEI : "BAD NEI NAME (Report to Github)"; + } + } + } + + public MTEIndustrialMultiMachine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialMultiMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialMultiMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Nine in One"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + String[] aBuiltStrings = new String[3]; + aBuiltStrings[0] = aToolTipNames[0] + ", " + aToolTipNames[1] + ", " + aToolTipNames[2]; + aBuiltStrings[1] = aToolTipNames[3] + ", " + aToolTipNames[4] + ", " + aToolTipNames[5]; + aBuiltStrings[2] = aToolTipNames[6] + ", " + aToolTipNames[7] + ", " + aToolTipNames[8]; + + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Multi-Machine") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the EU/t normally required") + .addInfo("Processes two items per voltage tier") + .addInfo("Machine Type: Metal - " + EnumChatFormatting.YELLOW + aBuiltStrings[0] + EnumChatFormatting.RESET) + .addInfo("Machine Type: Fluid - " + EnumChatFormatting.YELLOW + aBuiltStrings[1] + EnumChatFormatting.RESET) + .addInfo("Machine Type: Misc - " + EnumChatFormatting.YELLOW + aBuiltStrings[2] + EnumChatFormatting.RESET) + .addInfo("Read Multi-Machine Manual for extra information") + .addInfo( + EnumChatFormatting.AQUA + "You can use Solidifier Hatch to solidify multiple liquids." + + EnumChatFormatting.RESET) + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Multi-Use Casings", 6, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialMultiMachine.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(getTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 2)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialMultiMachineActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialMultiMachine; + } + + @Override + protected int getCasingTextureId() { + return getTextureIndex(); + } + + @Override + public int getMaxParallelRecipes() { + return (2 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + switch (machineMode) { + case MACHINEMODE_METAL -> { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; + } + case MACHINEMODE_FLUID -> { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; + } + default -> { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; + } + } + } + + public int getTextureIndex() { + return TAE.getIndexFromPage(2, 2); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private ItemStack getCircuit(ItemStack[] t) { + for (ItemStack j : t) { + if (j.getItem() == GTUtility.getIntegratedCircuit(0) + .getItem()) { + if (j.getItemDamage() >= 20 && j.getItemDamage() <= 22) { + return j; + } + } + } + return null; + } + + private int getCircuitID(ItemStack circuit) { + int H = circuit.getItemDamage(); + int T = (H == 20 ? 0 : (H == 21 ? 1 : (H == 22 ? 2 : -1))); + return MODE_MAP[machineMode][T]; + } + + @Override + public RecipeMap getRecipeMap() { + return null; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList( + RecipeMaps.compressorRecipes, + RecipeMaps.latheRecipes, + RecipeMaps.polarizerRecipes, + RecipeMaps.fermentingRecipes, + RecipeMaps.fluidExtractionRecipes, + RecipeMaps.extractorRecipes, + RecipeMaps.laserEngraverRecipes, + RecipeMaps.autoclaveRecipes, + RecipeMaps.fluidSolidifierRecipes); + } + + @Override + public int getRecipeCatalystPriority() { + return -10; + } + + private static RecipeMap getRecipeMap(int aMode) { + if (aMode == MODE_COMPRESSOR) { + return RecipeMaps.compressorRecipes; + } else if (aMode == MODE_LATHE) { + return RecipeMaps.latheRecipes; + } else if (aMode == MODE_MAGNETIC) { + return RecipeMaps.polarizerRecipes; + } else if (aMode == MODE_FERMENTER) { + return RecipeMaps.fermentingRecipes; + } else if (aMode == MODE_FLUIDEXTRACT) { + return RecipeMaps.fluidExtractionRecipes; + } else if (aMode == MODE_EXTRACTOR) { + return RecipeMaps.extractorRecipes; + } else if (aMode == MODE_LASER) { + return RecipeMaps.laserEngraverRecipes; + } else if (aMode == MODE_AUTOCLAVE) { + return RecipeMaps.autoclaveRecipes; + } else if (aMode == MODE_FLUIDSOLIDIFY) { + return RecipeMaps.fluidSolidifierRecipes; + } else { + return null; + } + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + private ItemStack lastCircuit = null; + private int lastMode = -1; + + @Nonnull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + ItemStack circuit = getCircuit(inputItems); + if (circuit == null) { + return Stream.empty(); + } + if (!GTUtility.areStacksEqual(circuit, lastCircuit)) { + lastRecipe = null; + lastCircuit = circuit; + } + if (machineMode != lastMode) { + lastRecipe = null; + lastMode = machineMode; + } + RecipeMap foundMap = getRecipeMap(getCircuitID(circuit)); + if (foundMap == null) { + return Stream.empty(); + } + return super.findRecipeMatches(foundMap); + } + }.setSpeedBonus(1F / 3.5F) + .setEuModifier(0.8F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_MULTI_MACHINE.mode." + machineMode); + } + + @Override + public String[] getInfoData() { + String[] data = super.getInfoData(); + ArrayList mInfo = new ArrayList<>(Arrays.asList(data)); + String mode; + switch (machineMode) { + case MACHINEMODE_METAL -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.metal"); + case MACHINEMODE_FLUID -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.fluid"); + default -> mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.misc"); + } + mInfo.add(mode); + return mInfo.toArray(new String[0]); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mInternalMode")) { + machineMode = aNBT.getInteger("mInternalMode"); + } + super.loadNBTData(aNBT); + } + + @Override + public boolean isInputSeparationEnabled() { + return true; + } + + @Override + protected CheckRecipeResult doCheckRecipe() { + + if (machineMode != MACHINEMODE_MISC || !isInputSeparationEnabled()) { + return super.doCheckRecipe(); + } else { + CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE; + + // check crafting input hatches first + if (supportsCraftingMEBuffer()) { + for (IDualInputHatch dualInputHatch : mDualInputHatches) { + for (var it = dualInputHatch.inventories(); it.hasNext();) { + IDualInputInventory slot = it.next(); + processingLogic.setInputItems(slot.getItemInputs()); + processingLogic.setInputFluids(slot.getFluidInputs()); + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + } + } + + // Logic for GT_MetaTileEntity_Hatch_Solidifier + for (MTEHatchInput solidifierHatch : mInputHatches) { + if (solidifierHatch instanceof MTEHatchSolidifier) { + ItemStack mold = ((MTEHatchSolidifier) solidifierHatch).getMold(); + FluidStack fluid = solidifierHatch.getFluid(); + + if (mold != null && fluid != null) { + List inputItems = new ArrayList<>(); + inputItems.add(mold); + inputItems.add(GTUtility.getIntegratedCircuit(22)); + + processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + processingLogic.setInputFluids(fluid); + + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + } + } + processingLogic.clear(); + processingLogic.setInputFluids(getStoredFluids()); + // Default logic + for (MTEHatchInputBus bus : mInputBusses) { + if (bus instanceof MTEHatchCraftingInputME) { + continue; + } + List inputItems = new ArrayList<>(); + for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stored = bus.getStackInSlot(i); + if (stored != null) { + inputItems.add(stored); + } + } + if (canUseControllerSlotForRecipe() && getControllerSlot() != null) { + inputItems.add(getControllerSlot()); + } + processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + CheckRecipeResult foundResult = processingLogic.process(); + if (foundResult.wasSuccessful()) { + return foundResult; + } + if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { + // Recipe failed in interesting way, so remember that and continue searching + result = foundResult; + } + } + + return result; + } + } + + @Override + public ArrayList getStoredFluids() { + ArrayList rList = new ArrayList<>(); + for (MTEHatchInput tHatch : filterValidMTEs(mInputHatches)) { + if (tHatch instanceof MTEHatchSolidifier) { + continue; + } + + setHatchRecipeMap(tHatch); + if (tHatch instanceof MTEHatchMultiInput) { + for (FluidStack tFluid : ((MTEHatchMultiInput) tHatch).getStoredFluid()) { + if (tFluid != null) { + rList.add(tFluid); + } + } + } else if (tHatch instanceof MTEHatchInputME) { + if (tHatch.isValid()) { + for (FluidStack fluidStack : ((MTEHatchInputME) tHatch).getStoredFluids()) { + if (fluidStack == null) continue; + rList.add(fluidStack); + } + } + } else { + if (tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + } + + return rList; + } + + @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); + tag.setInteger("mode", machineMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + if (tag.hasKey("mode")) { + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector + .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_MULTI_MACHINE.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } + + @Override + public int nextMachineMode() { + mLastRecipe = null; + if (machineMode == MACHINEMODE_METAL) return MACHINEMODE_FLUID; + else if (machineMode == MACHINEMODE_FLUID) return MACHINEMODE_MISC; + else return MACHINEMODE_METAL; + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_LPF_METAL); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_LPF_FLUID); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_DEFAULT); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialPlatePress.java new file mode 100644 index 0000000000..f41ebdd292 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialPlatePress.java @@ -0,0 +1,262 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +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 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 gregtech.api.enums.SoundResource; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialPlatePress extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + + private static final int MACHINEMODE_BENDER = 0; + private static final int MACHINEMODE_FORMER = 1; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialPlatePress(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialPlatePress(this.mName); + } + + @Override + public String getMachineType() { + return "Bending Machine, Forming Press"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Advanced Bending & Forming") + .addInfo("500% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Circuit for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different Circuit/Shape!") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Material Press Machine Casings", 6, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialPlatePress.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(50) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 4)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialPlatePressActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialPlatePress; + } + + @Override + protected int getCasingTextureId() { + return 50; + } + + @Override + public RecipeMap getRecipeMap() { + return (machineMode == MACHINEMODE_FORMER) ? RecipeMaps.formingPressRecipes : RecipeMaps.benderRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.formingPressRecipes, RecipeMaps.benderRecipes); + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 6F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (machineMode == MACHINEMODE_FORMER) + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + // Migrates old NBT tag to the new one + if (aNBT.hasKey("mFormingMode")) { + machineMode = aNBT.getBoolean("mFormingMode") ? MACHINEMODE_FORMER : MACHINEMODE_BENDER; + } + super.loadNBTData(aNBT); + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_BENDING); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_FORMING); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_PLATE_PRESS.mode." + machineMode); + } + + @Override + public boolean isInputSeparationEnabled() { + return true; + } + + @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); + tag.setInteger("mode", machineMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector + .translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_PLATE_PRESS.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialSifter.java new file mode 100644 index 0000000000..6dbd019887 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialSifter.java @@ -0,0 +1,208 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Random; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialSifter extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialSifter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialSifter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialSifter(this.mName); + } + + @Override + public String getMachineType() { + return "Sifter"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Sifter") + .addInfo("400% faster than single-block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 5, false) + .addController("Bottom Center") + .addCasingInfoMin("Sieve Grate", 18, false) + .addCasingInfoMin("Sieve Casings", 35, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC" }, + { "CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC" }, + { "CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialSifter.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(TAE.GTPP_INDEX(21)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 5)))) + .addElement('M', ofBlock(ModBlocks.blockCasings2Misc, 6)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 2, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 2, 0) && mCasing >= 35 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialSifterActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialSifter; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(21); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.sifterRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP) + && (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + if (tRandom.nextFloat() > 0.4) return; + + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * 2; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * 2; + + aBaseMetaTileEntity.getWorld() + .spawnParticle( + "smoke", + (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), + (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + 0.0, + 0.0, + 0.0); + } + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 5F) + .setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialThermalCentrifuge.java new file mode 100644 index 0000000000..b494d0bfa7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialThermalCentrifuge.java @@ -0,0 +1,183 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialThermalCentrifuge extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialThermalCentrifuge(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialThermalCentrifuge(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialThermalCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Thermal Centrifuge"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Thermal Centrifuge") + .addInfo("150% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the EU/t normally required") + .addInfo("Processes eight items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 2, 3, false) + .addController("Front Center") + .addCasingInfoMin("Thermal Processing Casings/Noise Hazard Sign Blocks", 8, false) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addMufflerHatch("Bottom Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][] { { "X~X", "XXX", "XXX" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEIndustrialThermalCentrifuge.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings3, 9)))) + .addElement( + 'X', + ofChain( + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings3, 9)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 0, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 0, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 0, 0) && mCasing >= 8 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialThermalCentrifugeActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialThermalCentrifuge; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.thermalCentrifugeRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.5F) + .setEuModifier(0.8F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(16); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialVacuumFreezer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialVacuumFreezer.java new file mode 100644 index 0000000000..3d18a9eda0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialVacuumFreezer.java @@ -0,0 +1,254 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTEHatchCustomFluidBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialVacuumFreezer extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mCryoFuelName = "Gelid Cryotheum"; + public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; + public static FluidStack mFuelStack; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private final ArrayList mCryotheumHatches = new ArrayList<>(); + + public MTEIndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + } + + public MTEIndustrialVacuumFreezer(final String aName) { + super(aName); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new MTEIndustrialVacuumFreezer(this.mName); + } + + @Override + public String getMachineType() { + return "Vacuum Freezer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Vacuum Freezer") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 4") + .addInfo("Consumes 10L of " + mCryoFuelName + "/s during operation") + .addInfo("Constructed exactly the same as a normal Vacuum Freezer") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin(mCasingName, 10, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addOtherStructurePart(mHatchName, "Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEIndustrialVacuumFreezer.class) + .adder(MTEIndustrialVacuumFreezer::addCryotheumHatch) + .hatchId(967) + .shouldReject(t -> !t.mCryotheumHatches.isEmpty()) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + buildHatchAdder(MTEIndustrialVacuumFreezer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 10)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mCryotheumHatches.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && !mCryotheumHatches.isEmpty(); + } + + private boolean addCryotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchCustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity() + .getMetaTileID() == 967) { + return addToMachineListInternal(mCryotheumHatches, aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void updateSlots() { + for (MTEHatchCustomFluidBase tHatch : filterValidMTEs(mCryotheumHatches)) tHatch.updateSlots(); + super.updateSlots(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialVacuumFreezerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialVacuumFreezer; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.advancedFreezerRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /* + * if (this.getBaseMetaTileEntity().isActive()) { if (!this.depleteInput(mFuelStack.copy())) { + * this.getBaseMetaTileEntity().setActive(false); } } + */ + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled()) { + if (aTick % 20 == 0 || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled()) { + if (!this.depleteInputFromRestrictedHatches(this.mCryotheumHatches, 10)) { + this.causeMaintenanceIssue(); + this.stopMachine( + ShutDownReasonRegistry + .outOfFluid(Objects.requireNonNull(FluidUtils.getFluidStack("cryotheum", 10)))); + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWashPlant.java new file mode 100644 index 0000000000..35d0867cee --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWashPlant.java @@ -0,0 +1,425 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.TAE; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +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.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEIndustrialWashPlant extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final int MACHINEMODE_OREWASH = 0; + private static final int MACHINEMODE_SIMPLEWASH = 1; + private static final int MACHINEMODE_CHEMBATH = 2; + + public MTEIndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialWashPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialWashPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Ore Washer, Simple Washer, Chemical Bath"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Wash Plant") + .addInfo("Can be configured with a screwdriver to also do Simple Washer and process Chemical Bathing") + .addInfo("400% faster than using single block machines of the same voltage") + .addInfo("Processes four item per voltage tier") + .addInfo("Always requires an Input Hatch full of water to refill structure") + .addInfo("Need to be filled with water.") + .addInfo("Will automatically fill water from input hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 7, true) + .addController("Front Center") + .addCasingInfoMin("Wash Plant Casings", 40, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCCCC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CCCCC" }, + { "CC~CC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CwwwC", "CCCCC" }, + { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialWashPlant.class) + .atLeast(InputBus, InputHatch, OutputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement( + 'w', + ofChain( + isAir(), + ofBlockAnyMeta(Blocks.water), + ofBlockAnyMeta(Blocks.flowing_water), + ofBlockAnyMeta(BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 1, 0) && mCasing >= 40 && checkHatch(); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a washer, water will flow out. + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialWashPlantActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialWashPlant; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public RecipeMap getRecipeMap() { + switch (machineMode) { + case MACHINEMODE_OREWASH -> { + return RecipeMaps.oreWasherRecipes; + } + case MACHINEMODE_SIMPLEWASH -> { + return GTPPRecipeMaps.simpleWasherRecipes; + } + default -> { + return RecipeMaps.chemicalBathRecipes; + } + } + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays + .asList(RecipeMaps.oreWasherRecipes, GTPPRecipeMaps.simpleWasherRecipes, RecipeMaps.chemicalBathRecipes); + } + + @Override + public int getRecipeCatalystPriority() { + return -10; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (checkForWater()) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + }.setSpeedBonus(1F / 5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (machineMode == MACHINEMODE_CHEMBATH) + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 4; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(11); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + if (mDirectionX == 0) { + mCurrentDirectionX = 2; + mCurrentDirectionZ = 3; + mOffsetX_Lower = -2; + mOffsetX_Upper = 2; + mOffsetZ_Lower = -3; + mOffsetZ_Upper = 3; + } else { + mCurrentDirectionX = 3; + mCurrentDirectionZ = 2; + mOffsetX_Lower = -3; + mOffsetX_Upper = 3; + mOffsetZ_Lower = -2; + mOffsetZ_Upper = 2; + } + + // if (aBaseMetaTileEntity.fac) + + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; ++h) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == Blocks.water) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = null; + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water) { + fluidUsed = Blocks.water; + } + if (tBlock == Blocks.water) { + fluidUsed = BlocksItems.getFluidBlock(InternalName.fluidDistilledWater); + } + aBaseMetaTileEntity.getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + if (tBlock == Blocks.water) { + ++tAmount; + // Utils.LOG_WARNING("Found Water"); + } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + ++tAmount; + ++tAmount; + // Utils.LOG_WARNING("Found Distilled Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 45; + if (isValidWater) { + Logger.WARNING("Filled structure."); + } else { + Logger.WARNING("Did not fill structure."); + } + return isValidWater; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mChemicalMode")) { + boolean aTempMode = aNBT.getBoolean("mChemicalMode"); + if (aTempMode) { + machineMode = 2; + } else { + machineMode = 0; + } + aNBT.removeTag("mChemicalMode"); + } + if (aNBT.hasKey("mMode")) { + machineMode = aNBT.getInteger("mMode"); + } + super.loadNBTData(aNBT); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + machineMode); + } + + @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); + tag.setInteger("mode", machineMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } + + @Override + public int nextMachineMode() { + if (machineMode == MACHINEMODE_OREWASH) return MACHINEMODE_SIMPLEWASH; + else if (machineMode == MACHINEMODE_SIMPLEWASH) return MACHINEMODE_CHEMBATH; + else return MACHINEMODE_OREWASH; + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_WASHPLANT); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_SIMPLEWASHER); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_CHEMBATH); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWireMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWireMill.java new file mode 100644 index 0000000000..292fd1041b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialWireMill.java @@ -0,0 +1,212 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraftforge.common.util.ForgeDirection; + +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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialWireMill extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialWireMill(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialWireMill(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialWireMill(this.mName); + } + + @Override + public String getMachineType() { + return "Wiremill"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Wire Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the EU/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfoMin("Wire Factory Casings", 14, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC", "CCC", "CCC" }, { "C~C", "C-C", "C-C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialWireMill.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 14 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_RECYCLER_OP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialWireMillActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialWireMill; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(6); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.wiremillRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F) + .setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + aPlayer.addChatMessage( + new ChatComponentTranslation( + inputSeparation ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 6; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(6); + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIsaMill.java new file mode 100644 index 0000000000..d1a6ac34f0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIsaMill.java @@ -0,0 +1,527 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.MTEHatchMillingBalls; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTEIsaMill extends GTPPMultiBlockBase implements ISurvivalConstructable { + + protected boolean boostEu = false; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final IIconContainer frontFaceActive = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); + private static final IIconContainer frontFace = new CustomIcon("iconsets/Grinder/GRINDER5"); + + private final ArrayList mMillingBallBuses = new ArrayList<>(); + private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); + + public MTEIsaMill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIsaMill(String aName) { + super(aName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Grinding Machine") + .addInfo("Grind ores.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 7, false) + .addController("Front Center") + .addCasingInfoMin("IsaMill Exterior Casing", 40, false) + .addOtherStructurePart("IsaMill Gearbox", "5x, Inner Blocks") + .addOtherStructurePart("IsaMill Piping", "8x, ring around controller") + .addStructureInfo("IsaMill Pipings must not be obstructed in front (only air blocks)") + .addOtherStructurePart("Milling Ball Hatch", "Any Casing") + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC" }, + { "D~D", "CGC", "CGC", "CGC", "CGC", "CGC", "CCC" }, + { "DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEIsaMill.class).adder(MTEIsaMill::addMillingBallsHatch) + .hatchClass(MTEHatchMillingBalls.class) + .shouldReject(t -> !t.mMillingBallBuses.isEmpty()) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + buildHatchAdder(MTEIsaMill.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('D', ofBlock(getIntakeBlock(), getIntakeMeta())) + .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mMillingBallBuses.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 48 - 8 && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && mMillingBallBuses.size() == 1; + } + + @Override + protected IIconContainer getActiveOverlay() { + return frontFaceActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return frontFace; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(2); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + private boolean addMillingBallsHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchMillingBalls) { + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchMillingBalls) { + log("Found GT_MetaTileEntity_Hatch_MillingBalls"); + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.millingRecipes; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mMillingBallBuses.clear(); + } + } + if (aTick % 20 == 0 && isMachineRunning()) { + checkForEntities(aBaseMetaTileEntity, aTick); + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + private final AutoMap mFrontBlockPosCache = new AutoMap<>(); + + public void checkForEntities(IGregTechTileEntity aBaseMetaTileEntity, long aTime) { + + if (aTime % 100 == 0) { + mFrontBlockPosCache.clear(); + } + if (mFrontBlockPosCache.isEmpty()) { + ForgeDirection tSide = aBaseMetaTileEntity.getBackFacing(); + int aTileX = aBaseMetaTileEntity.getXCoord(); + int aTileY = aBaseMetaTileEntity.getYCoord(); + int aTileZ = aBaseMetaTileEntity.getZCoord(); + boolean xFacing = tSide.offsetX != 0; + boolean zFacing = tSide.offsetZ != 0; + + // Check Casings + int aDepthOffset = (tSide == ForgeDirection.NORTH || tSide == ForgeDirection.WEST) ? 1 : -1; + for (int aHorizontalOffset = -1; aHorizontalOffset < 2; aHorizontalOffset++) { + for (int aVerticalOffset = -1; aVerticalOffset < 2; aVerticalOffset++) { + int aX = !xFacing ? (aTileX + aHorizontalOffset) : (aTileX + aDepthOffset); + int aY = aTileY + aVerticalOffset; + int aZ = !zFacing ? (aTileZ + aHorizontalOffset) : (aTileZ + aDepthOffset); + mFrontBlockPosCache.add(new BlockPos(aX, aY, aZ, aBaseMetaTileEntity.getWorld())); + } + } + } + + AutoMap aEntities = getEntities(mFrontBlockPosCache, aBaseMetaTileEntity.getWorld()); + if (!aEntities.isEmpty()) { + for (EntityLivingBase aFoundEntity : aEntities) { + if (aFoundEntity instanceof EntityPlayer aPlayer) { + if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { + continue; + } else { + if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, getPlayerDamageValue(aPlayer, 10)); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } else if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage( + aFoundEntity, + mIsaMillDamageSource, + Math.max(1, (int) (aFoundEntity.getMaxHealth() / 3))); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } + } + + // 20 armor points add 80% damage reduction, more points add more damage reduction + private int getPlayerDamageValue(EntityPlayer player, int damage) { + int armorValue = player.getTotalArmorValue(); + int reducedDamage = (int) (damage - damage * (armorValue * 0.04)); + return Math.max(reducedDamage, 0); + } + + private static AutoMap getEntities(AutoMap aPositionsToCheck, World aWorld) { + AutoMap aEntities = new AutoMap<>(); + HashSet aChunksToCheck = new HashSet<>(); + if (!aPositionsToCheck.isEmpty()) { + Chunk aLocalChunk; + for (BlockPos aPos : aPositionsToCheck) { + aLocalChunk = aWorld.getChunkFromBlockCoords(aPos.xPos, aPos.zPos); + aChunksToCheck.add(aLocalChunk); + } + } + if (!aChunksToCheck.isEmpty()) { + AutoMap aEntitiesFound = new AutoMap<>(); + for (Chunk aChunk : aChunksToCheck) { + if (aChunk.isChunkLoaded) { + List[] aEntityLists = aChunk.entityLists; + for (List aEntitySubList : aEntityLists) { + for (Object aEntity : aEntitySubList) { + if (aEntity instanceof EntityLivingBase aPlayer) { + aEntitiesFound.add(aPlayer); + } + } + } + } + } + if (!aEntitiesFound.isEmpty()) { + for (EntityLivingBase aEntity : aEntitiesFound) { + BlockPos aPlayerPos = EntityUtils.findBlockPosOfEntity(aEntity); + for (BlockPos aBlockSpaceToCheck : aPositionsToCheck) { + if (aBlockSpaceToCheck.equals(aPlayerPos)) { + aEntities.add(aEntity); + } + } + } + } + } + return aEntities; + } + + private static void generateParticles(EntityLivingBase aEntity) { + BlockPos aPlayerPosBottom = EntityUtils.findBlockPosOfEntity(aEntity); + BlockPos aPlayerPosTop = aPlayerPosBottom.getUp(); + AutoMap aEntityPositions = new AutoMap<>(); + aEntityPositions.add(aPlayerPosBottom); + aEntityPositions.add(aPlayerPosTop); + for (int i = 0; i < 64; i++) { + BlockPos aEffectPos = aEntityPositions.get(aEntity.height > 1f ? MathUtils.randInt(0, 1) : 0); + float aOffsetX = MathUtils.randFloat(-0.35f, 0.35f); + float aOffsetY = MathUtils.randFloat(-0.25f, 0.35f); + float aOffsetZ = MathUtils.randFloat(-0.35f, 0.35f); + aEntity.worldObj.spawnParticle( + "reddust", + aEffectPos.xPos + aOffsetX, + aEffectPos.yPos + 0.3f + aOffsetY, + aEffectPos.zPos + aOffsetZ, + 0.0D, + 0.0D, + 0.0D); + } + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public Block getIntakeBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getIntakeMeta() { + return 1; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getGearboxMeta() { + return 2; + } + + public byte getCasingTextureIndex() { + return 66; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEIsaMill(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIsaMill; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { "IsaMill Grinding Machine", "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String getMachineType() { + return "Grinding Machine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + /* + * Milling Ball Handling + */ + + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + for (MTEHatchMillingBalls tHatch : filterValidMTEs(mMillingBallBuses)) { + AutoMap aHatchContent = tHatch.getContentUsageSlots(); + if (!aHatchContent.isEmpty()) { + tItems.addAll(aHatchContent); + } + } + return tItems; + } + + public int getMaxBallDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxBallDurability(aStack); + } + + private ItemStack findMillingBall(ItemStack[] aItemInputs) { + if (mMillingBallBuses.size() != 1) { + return null; + } else { + MTEHatchMillingBalls aBus = mMillingBallBuses.get(0); + if (aBus != null) { + AutoMap aAvailableItems = aBus.getContentUsageSlots(); + if (!aAvailableItems.isEmpty()) { + for (final ItemStack aInput : aItemInputs) { + if (ItemUtils.isMillingBall(aInput)) { + for (ItemStack aBall : aAvailableItems) { + if (GTUtility.areStacksEqual(aBall, aInput, true)) { + Logger.INFO("Found a valid milling ball to use."); + return aBall; + } + } + } + } + } + } + } + return null; + } + + private void damageMillingBall(ItemStack aStack) { + if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * 1))) { + int damage = getMillingBallDamage(aStack) + 1; + log("damage milling ball " + damage); + if (damage >= getMaxBallDurability(aStack)) { + log("consuming milling ball"); + aStack.stackSize -= 1; + } else { + setDamage(aStack, damage); + } + } else { + log("not damaging milling ball"); + } + } + + private int getMillingBallDamage(ItemStack aStack) { + return ItemGenericChemBase.getMillingBallDamage(aStack); + } + + private void setDamage(ItemStack aStack, int aAmount) { + ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + ItemStack millingBall; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + millingBall = findMillingBall(inputItems); + if (millingBall == null) { + return SimpleCheckRecipeResult.ofFailure("no_milling_ball"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (result.wasSuccessful()) { + damageMillingBall(millingBall); + } + return result; + } + }.enablePerfectOverclock(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTENuclearSaltProcessingPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTENuclearSaltProcessingPlant.java new file mode 100644 index 0000000000..139ea00d82 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTENuclearSaltProcessingPlant.java @@ -0,0 +1,222 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.item.ItemStack; + +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTENuclearSaltProcessingPlant extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + protected GTRecipe lastRecipeToBuffer; + private int casing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTENuclearSaltProcessingPlant(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTENuclearSaltProcessingPlant(String mName) { + super(mName); + } + + @Override + public String getMachineType() { + return "Reactor Processing Unit, Cold Trap"; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity tileEntity) { + return new MTENuclearSaltProcessingPlant(this.mName); + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Nuclear Salt Processing Plant") + .addInfo("Processes depleted nuclear salts that come from the LFTR") + .addInfo("Handles the recipes of the Reactor Processor Unit and Cold Trap") + .addInfo("Only Thermally Insulated Casings can be replaced with hatches") + .addInfo("Mufflers on top, Energy Hatches on bottom, exactly 2 of each are required") + .addInfo("Maintenance Hatch goes on the back, opposite of the controller block") + .addInfo("Inputs go on the left side of the multi, outputs on the right side") + .addInfo("150% faster than using single block machines of the same voltage") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("IV Machine Casing", 58, false) + .addCasingInfoMin("Thermally Insulated Casing", 1, false) + .addInputBus("Left Half", 2) + .addInputHatch("Left Half", 2) + .addOutputBus("Right Half", 3) + .addOutputHatch("Right Half", 3) + .addMufflerHatch("Top Side, 2 Required", 4) + .addEnergyHatch("Bottom Side, 2 Required", 5) + .addMaintenanceHatch("Back Side, Opposite of Controller", 6) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 10); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "AAA AAA", "ADA ADA", "AAA AAA" }, + { "ABBA ACCA", "B AAA C", "ABBA ACCA" }, { "ABBB~CCCA", "B C", "ABBBFCCCA" }, + { "ABBA ACCA", "B AAA C", "ABBA ACCA" }, { "AAA AAA", "AEA AEA", "AAA AAA" } })) + .addElement('A', ofBlock(GregTechAPI.sBlockCasings1, 5)) + .addElement( + 'B', + buildHatchAdder(MTENuclearSaltProcessingPlant.class).atLeast(InputBus, InputHatch) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(2) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) + .addElement( + 'C', + buildHatchAdder(MTENuclearSaltProcessingPlant.class).atLeast(OutputBus, OutputHatch) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(3) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) + .addElement( + 'D', + buildHatchAdder(MTENuclearSaltProcessingPlant.class).atLeast(Muffler) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(4) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) + .addElement( + 'E', + buildHatchAdder(MTENuclearSaltProcessingPlant.class).atLeast(Energy) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(5) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) + .addElement( + 'F', + buildHatchAdder(MTENuclearSaltProcessingPlant.class).atLeast(Maintenance) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(6) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockSpecialMultiCasings, 8)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack itemStack, boolean hintsOnly) { + buildPiece(mName, itemStack, hintsOnly, 4, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, itemStack, 4, 2, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity baseMetaTileEntity, ItemStack itemStack) { + casing = 0; + return checkPiece(mName, 4, 2, 0) && checkHatch(); + } + + @Override + public boolean checkHatch() { + return mEnergyHatches.size() == 2 && mMufflerHatches.size() == 2 && super.checkHatch(); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.nuclearSaltProcessingPlantRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.5F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return 2 * (Math.max(1, GTUtility.getTier(getMaxInputVoltage()))); + } + + @Override + public String[] getExtraInfoData() { + final String running = (this.mMaxProgresstime > 0 ? "Salt Plant running" : "Salt Plant stopped"); + final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" + : "Needs Maintenance"); + String tSpecialText; + + if (lastRecipeToBuffer != null && lastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { + tSpecialText = "Currently processing: " + lastRecipeToBuffer.mOutputs[0].getDisplayName(); + } else { + tSpecialText = "Currently processing: Nothing"; + } + + return new String[] { "Nuclear Salt Processing Plant", running, maintenance, tSpecialText }; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTESpargeTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTESpargeTower.java new file mode 100644 index 0000000000..d78bbc0e45 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTESpargeTower.java @@ -0,0 +1,498 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; + +import java.util.ArrayList; +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.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.GTValues; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.fluid.IFluidStore; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.GasSpargingRecipe; +import gregtech.api.util.GasSpargingRecipeMap; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTESpargeTower extends GTPPMultiBlockBase implements ISurvivalConstructable { + + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; + private static final IStructureDefinition STRUCTURE_DEFINITION; + + static { + IHatchElement layeredOutputHatch = OutputHatch + .withCount(MTESpargeTower::getCurrentLayerOutputHatchCount) + .withAdder(MTESpargeTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" }, })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "lll", "lcl", "lll" } })) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] { { "lll", "l-l", "lll" } })) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] { { "lll", "lll", "lll" } })) + .addElement( + 'b', + buildHatchAdder(MTESpargeTower.class).atLeast(Energy, InputHatch, InputBus, Maintenance) + .disallowOnly(ForgeDirection.UP) + .casingIndex(getCasingIndex()) + .dot(1) + .buildAndChain( + onElementPass(MTESpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4)))) + .addElement( + 'l', + ofChain( + buildHatchAdder(MTESpargeTower.class).atLeast(layeredOutputHatch) + .disallowOnly(ForgeDirection.UP, ForgeDirection.DOWN) + .casingIndex(getCasingIndex()) + .dot(2) + .build(), + ofHatchAdder(MTESpargeTower::addEnergyInputToMachineList, getCasingIndex(), 2), + ofHatchAdder(MTESpargeTower::addMaintenanceToMachineList, getCasingIndex(), 2), + onElementPass(MTESpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4)))) + .addElement( + 'c', + ofChain( + onElementPass( + t -> t.onTopLayerFound(false), + ofHatchAdder(MTESpargeTower::addOutputToMachineList, getCasingIndex(), 3)), + onElementPass( + t -> t.onTopLayerFound(false), + ofHatchAdder(MTESpargeTower::addMaintenanceToMachineList, getCasingIndex(), 3)), + onElementPass(t -> t.onTopLayerFound(true), ofBlock(ModBlocks.blockCasings5Misc, 4)), + isAir())) + .build(); + } + + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + public MTESpargeTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTESpargeTower(String aName) { + super(aName); + } + + public static int getCasingIndex() { + return 68; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESpargeTower(this.mName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Gas Sparge Tower") + .addInfo("Controller block for the Sparging Tower") + .addInfo("Runs gases through depleted molten salts to extract precious fluids") + .addInfo("Works the same way as the Distillation Tower, but with a fixed height of 8") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginStructureBlock(3, 8, 3, true) + .addController("Front bottom") + .addOtherStructurePart("Sparge Tower Exterior Casing", "45 (minimum)") + .addEnergyHatch("Any casing", 1, 2) + .addMaintenanceHatch("Any casing", 1, 2, 3) + .addInputHatch("2x Input Hatches (Any bottom layer casing)", 1) + .addOutputHatch("6x Output Hatches (At least one per layer except bottom layer)", 2, 3) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCASpargeTowerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCASpargeTower; + } + + @Override + protected int getCasingTextureId() { + return getCasingIndex(); + } + + @Override + public RecipeMap getRecipeMap() { + if (GTPPRecipeMaps.spargeTowerFakeRecipes.getAllRecipes() + .isEmpty()) { + generateRecipes(); + } + return GTPPRecipeMaps.spargeTowerFakeRecipes; + } + + private static boolean generateRecipes() { + for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { + GTRecipe newRecipe = new GTRecipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, + null, + aRecipe.mFluidInputs.clone(), + new FluidStack[] {}, + aRecipe.mDuration, + aRecipe.mEUt, + 0); + GTPPRecipeMaps.spargeTowerFakeRecipes.add(newRecipe); + } + return !GTPPRecipeMaps.spargeTowerFakeRecipes.getAllRecipes() + .isEmpty(); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + ArrayList tFluidList = getStoredFluids(); + long tVoltage = GTUtility.roundUpVoltage(this.getMaxInputVoltage()); + byte tTier = (byte) Math.max(0, GTUtility.getTier(tVoltage)); + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); + if (tFluids.length > 0) { + GTRecipe tRecipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, GTValues.V[tTier], tFluids); + if (tRecipe != null) { + FluidStack[] possibleOutputs = getPossibleByproductsOfSparge( + tRecipe.mFluidInputs[0], + tRecipe.mFluidInputs[1]).toArray(new FluidStack[0]); + if (canOutputAll(possibleOutputs) && tRecipe.isRecipeInputEqual(true, tFluids)) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + calculateOverclockedNessMulti((long) tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + mMaxProgresstime = Math.max(1, mMaxProgresstime); + ArrayList aFluidOutputs = getByproductsOfSparge( + tRecipe.mFluidInputs[0], + tRecipe.mFluidInputs[1]); + this.mOutputFluids = aFluidOutputs.toArray(new FluidStack[0]); + updateSlots(); + + if (lEUt > 0) { + lEUt = (-lEUt); + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + } + } + this.lEUt = 0; + this.mEfficiency = 0; + return CheckRecipeResultRegistry.NO_RECIPE; + } + + private static List getPossibleByproductsOfSparge(final FluidStack aSpargeGas, + final FluidStack aSpentFuel) { + GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); + ArrayList aOutputGases = new ArrayList<>(); + if (aSpargeRecipe == null) { + return aOutputGases; + } + + aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); + ArrayList aTempMap = new ArrayList<>(); + for (int i = 2; i < aSpargeRecipe.mFluidOutputs.length; i++) { + int aGasAmount = aSpargeRecipe.mMaxOutputQuantity[i - 2] / 100; + FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); + FluidStack aSpargeOutput = null; + if (aGasAmount > 0) { + aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); + } + aTempMap.add(aSpargeOutput); + } + aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeRecipe.mInputGas.amount)); + aOutputGases.addAll(aTempMap); + return aOutputGases; + } + + private static ArrayList getByproductsOfSparge(final FluidStack aSpargeGas, + final FluidStack aSpentFuel) { + GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); + ArrayList aOutputGases = new ArrayList<>(); + if (aSpargeRecipe == null) { + Logger.INFO("Did not find sparge recipe!"); + return aOutputGases; + } + int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; + + aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); + ArrayList aTempMap = new ArrayList<>(); + for (int i = 2; i < aSpargeRecipe.mFluidOutputs.length; i++) { + int aGasAmount = MathUtils.randInt(0, (aSpargeRecipe.mMaxOutputQuantity[i - 2] / 100)); + FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); + aSpargeGasAmount -= aGasAmount; + FluidStack aSpargeOutput = null; + if (aGasAmount > 0) { + aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); + } + aTempMap.add(aSpargeOutput); + } + Logger.INFO("Sparge gas left: " + aSpargeGasAmount); + if (aSpargeGasAmount > 0) { + aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); + } + // Logger.INFO("Sparge Outputs: "+ItemUtils.getArrayStackNames(aTempMap)); + aOutputGases.addAll(aTempMap); + Logger.INFO("Sparge output size: " + aOutputGases.size()); + // Logger.INFO("Output of sparging: "+ItemUtils.getArrayStackNames(aOutputGases)); + return aOutputGases; + } + + protected void onCasingFound() { + mCasing++; + } + + protected void onTopLayerFound(boolean aIsCasing) { + mTopLayerFound = true; + if (aIsCasing) { + onCasingFound(); + } + } + + protected int getCurrentLayerOutputHatchCount() { + return mOutputHatchesByLayer.size() < mHeight || mHeight <= 0 ? 0 + : mOutputHatchesByLayer.get(mHeight - 1) + .size(); + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null || aTileEntity.isDead() + || !(aTileEntity.getMetaTileEntity() instanceof MTEHatchOutput tHatch)) { + Logger.INFO("Bad Output Hatch"); + return false; + } + while (mOutputHatchesByLayer.size() < mHeight) { + mOutputHatchesByLayer.add(new ArrayList<>()); + } + tHatch.updateTexture(aBaseCasingIndex); + boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1) + .add(tHatch); + Logger.INFO("Added Hatch: " + addedHatch); + return addedHatch; + } + + @Override + public List getFluidOutputSlots(FluidStack[] toOutput) { + return getFluidOutputSlotsByLayer(toOutput, mOutputHatchesByLayer); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + mCasing = 0; + + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) { + Logger.INFO("Bad Base. Height: " + mHeight); + return false; + } + + // check each layer + while (mHeight < 8 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1) + .isEmpty()) { + // layer without output hatch + Logger.INFO("Height: " + mHeight + " - Missing output on " + (mHeight - 1)); + return false; + } + // not top + mHeight++; + } + + // validate final invariants... + Logger.INFO("Height: " + mHeight); + Logger.INFO("Casings: " + mCasing); + Logger.INFO("Required: " + (7 * mHeight - 5)); + Logger.INFO("Found Top: " + mTopLayerFound); + return mCasing >= 45 && mTopLayerFound && mMaintenanceHatches.size() == 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i] != null ? mOutputFluids2[i].copy() : null; + if (tStack == null) { + continue; + } + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) { + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); + } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + mHeight = 0; + int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, env, false, true); + if (built >= 0) return built; + int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + mHeight = i; + built = survivialBuildPiece( + STRUCTURE_PIECE_LAYER_HINT, + stackSize, + 1, + i, + 0, + elementBudget, + env, + false, + true); + if (built >= 0) return built; + } + mHeight = tTotalHeight - 1; + return survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, + stackSize, + 1, + tTotalHeight - 1, + 0, + elementBudget, + env, + false, + true); + } + + @Override + public String getMachineType() { + return "Gas Sparger"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public boolean onPlungerRightClick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { + int aLayerIndex = 0; + PlayerUtils + .messagePlayer(aPlayer, "Trying to clear " + mOutputHatchesByLayer.size() + " layers of output hatches."); + for (List layer : this.mOutputHatchesByLayer) { + int aHatchIndex = 0; + for (MTEHatchOutput hatch : layer) { + if (hatch.mFluid != null) { + PlayerUtils.messagePlayer( + aPlayer, + "Clearing " + hatch.mFluid.amount + + "L of " + + hatch.mFluid.getLocalizedName() + + " from hatch " + + aHatchIndex + + " on layer " + + aLayerIndex + + "."); + hatch.mFluid = null; + } + aHatchIndex++; + } + aLayerIndex++; + } + return aLayerIndex > 0; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + // Ensure that lEUt is negative from loaded NBT data, since this multi consumes EU + if (lEUt > 0) { + lEUt = (-lEUt); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEndustrialElectrolyzer.java new file mode 100644 index 0000000000..487e22f3f2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEndustrialElectrolyzer.java @@ -0,0 +1,168 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEndustrialElectrolyzer extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEndustrialElectrolyzer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEndustrialElectrolyzer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEndustrialElectrolyzer(this.mName); + } + + @Override + public String getMachineType() { + return "Electrolyzer"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Electrolyzer") + .addInfo("180% faster than using single block machines of the same voltage") + .addInfo("Only uses 90% of the EU/t normally required") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Electrolyzer Casings", 6, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEndustrialElectrolyzer.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(TAE.GTPP_INDEX(5)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 5)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDIndustrialElectrolyzerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDIndustrialElectrolyzer; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(5); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.electrolyzerNonCellRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.8F) + .setEuModifier(0.9F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * GTUtility.getTier(this.getMaxInputVoltage()); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java deleted file mode 100644 index 0befc6f7c7..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java +++ /dev/null @@ -1,519 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -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 net.minecraftforge.fluids.FluidStack; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IHatchElement; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_Adv_DistillationTower extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private Mode mMode = Mode.DistillationTower; - private boolean mUpgraded = false; - - protected static final String STRUCTURE_PIECE_BASE = "base"; - protected static final String STRUCTURE_PIECE_LAYER = "layer"; - protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; - protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; - - protected final List> mOutputHatchesByLayer = new ArrayList<>(); - protected int mHeight; - protected int mCasing; - protected boolean mTopLayerFound; - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Adv_DistillationTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_DistillationTower(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_DistillationTower(this.mName); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - IHatchElement layeredOutputHatch = OutputHatch - .withCount(GregtechMetaTileEntity_Adv_DistillationTower::getCurrentLayerOutputHatchCount) - .withAdder(GregtechMetaTileEntity_Adv_DistillationTower::addLayerOutputHatch); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" }, })) - .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "lll", "lcl", "lll" }, })) - .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] { { "lll", "l-l", "lll" }, })) - .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] { { "ttt", "ttt", "ttt" }, })) - .addElement( - 'b', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(Energy, OutputBus, InputHatch, InputBus, Maintenance) - .disallowOnly(ForgeDirection.UP) - .casingIndex(getCasingTextureId()) - .dot(1) - .build(), - ofBlock(GregTech_API.sBlockCasings4, 1))) - .addElement( - 'l', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(layeredOutputHatch, Energy, Maintenance) - .disallowOnly(ForgeDirection.UP, ForgeDirection.DOWN) - .casingIndex(getCasingTextureId()) - .dot(2) - .build(), - ofHatchAdder( - GregtechMetaTileEntity_Adv_DistillationTower::addMufflerToMachineList, - getCasingTextureId(), - 3), - ofBlock(GregTech_API.sBlockCasings4, 1))) - .addElement( - 'c', - ofChain( - onElementPass( - GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, - ofHatchAdder( - GregtechMetaTileEntity_Adv_DistillationTower::addMufflerToMachineList, - getCasingTextureId(), - 3)), - onElementPass( - GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, - ofHatchAdder( - GregtechMetaTileEntity_Adv_DistillationTower::addOutputToMachineList, - getCasingTextureId(), - 3)), - onElementPass( - GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, - ofHatchAdder( - GregtechMetaTileEntity_Adv_DistillationTower::addMaintenanceToMachineList, - getCasingTextureId(), - 3)), - onElementPass( - GregtechMetaTileEntity_Adv_DistillationTower::onTopLayerFound, - ofBlock(GregTech_API.sBlockCasings4, 1)), - isAir())) - .addElement( - 't', - buildHatchAdder(GregtechMetaTileEntity_Adv_DistillationTower.class) - .atLeast(layeredOutputHatch, Muffler) - .disallowOnly(ForgeDirection.DOWN) - .casingIndex(getCasingTextureId()) - .dot(2) - .buildAndChain(GregTech_API.sBlockCasings4, 1)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - protected int getCurrentLayerOutputHatchCount() { - return mOutputHatchesByLayer.size() < mHeight || mHeight <= 0 ? 0 - : mOutputHatchesByLayer.get(mHeight - 1) - .size(); - } - - protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null || aTileEntity.isDead() - || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output tHatch)) return false; - while (mOutputHatchesByLayer.size() < mHeight) mOutputHatchesByLayer.add(new ArrayList<>()); - tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatchesByLayer.get(mHeight - 1) - .add(tHatch) && mOutputHatches.add(tHatch); - } - - protected void onTopLayerFound() { - mTopLayerFound = true; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Advanced Distillation Tower") - .addInfo("Use 85% less energy in distillery mode") - .addInfo("250%/100% faster in DT/distillery mode") - .addInfo("Right click the controller with screwdriver to change mode.") - .addInfo("Max parallel dictated by tower tier and mode") - .addInfo("DTower Mode: T1=4, T2=12") - .addInfo("Distillery Mode: Tower Tier * (4*InputTier)") - .addInfo("Distillery Mode require a full height tower") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addCasingInfoMin("Clean Stainless Steel Machine Casing", 7, false) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addOutputHatch("One per layer except bottom", 2) - .addMufflerHatch("Top Casing", 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); - } - buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - mHeight = 0; - int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, env, false, true); - if (built >= 0) return built; - int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height - for (int i = 1; i < tTotalHeight - 1; i++) { - mHeight = i; - built = survivialBuildPiece( - STRUCTURE_PIECE_LAYER_HINT, - stackSize, - 1, - i, - 0, - elementBudget, - env, - false, - true); - if (built >= 0) return built; - } - mHeight = tTotalHeight - 1; - return survivialBuildPiece( - STRUCTURE_PIECE_TOP_HINT, - stackSize, - 1, - tTotalHeight - 1, - 0, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - // reset - mOutputHatchesByLayer.forEach(List::clear); - mHeight = 1; - mTopLayerFound = false; - - // check base - if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) return false; - - // check each layer - while (mHeight < 12) { - if (!checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) { - return false; - } - if (mOutputHatchesByLayer.size() < mHeight || mOutputHatchesByLayer.get(mHeight - 1) - .isEmpty()) - // layer without output hatch - return false; - if (mTopLayerFound || !mMufflerHatches.isEmpty()) { - break; - } - // not top - mHeight++; - } - boolean check = mTopLayerFound && mHeight >= 2 && checkHatch(); - if (check && mHeight < 11) { - // force the mode to DT if not in full height - mMode = Mode.DistillationTower; - mLastRecipe = null; - } - return check; - } - - @Override - public RecipeMap getRecipeMap() { - return mMode.getRecipeMap(); - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.distilleryRecipes, RecipeMaps.distillationTowerRecipes); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - if (this.mMode == Mode.Distillery) - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mMode", (byte) mMode.ordinal()); - aNBT.setBoolean("mUpgraded", mUpgraded); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mMode = Mode.values()[aNBT.getByte("mMode")]; - mUpgraded = aNBT.getBoolean("mUpgraded"); - super.loadNBTData(aNBT); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (mHeight < 11) { - PlayerUtils.messagePlayer(aPlayer, "Cannot switch mode if not in full height."); - return; - } - mMode = mMode.next(); - PlayerUtils.messagePlayer(aPlayer, "Now running in " + mMode + " Mode."); - mLastRecipe = null; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) return false; - FluidStack copiedFluidStack = aLiquid.copy(); - for (List hatches : mOutputHatchesByLayer) { - if (dumpFluid(hatches, copiedFluidStack, true)) return true; - } - for (List hatches : mOutputHatchesByLayer) { - if (dumpFluid(hatches, copiedFluidStack, false)) return true; - } - return false; - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - if (mMode == Mode.DistillationTower) { - // dt mode - for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { - FluidStack tStack = mOutputFluids2[i].copy(); - if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) - dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); - } - } else { - // distillery mode - for (FluidStack outputFluidStack : mOutputFluids2) { - addOutput(outputFluidStack); - } - } - } - - @Override - public List getFluidOutputSlots(FluidStack[] toOutput) { - return getFluidOutputSlotsByLayer(toOutput, mOutputHatchesByLayer); - } - - @Override - public String getMachineType() { - return "Distillery, Distillation Tower"; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void setupProcessingLogic(ProcessingLogic logic) { - super.setupProcessingLogic(logic); - logic.setEuModifier(mMode == Mode.Distillery ? 0.15F : 1F); - logic.setSpeedBonus(mMode == Mode.Distillery ? 1F / 2F : 1F / 3.5F); - } - - @Override - public int getMaxParallelRecipes() { - return switch (mMode) { - case DistillationTower -> getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0; - case Distillery -> getTierOfTower() * (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - default -> 0; - }; - } - - private int getTierOfTower() { - return mUpgraded ? 2 : 1; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; - } - - @Override - protected int getCasingTextureId() { - return 49; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aTick % 20 == 0 && !mUpgraded) { - ItemStack aGuiStack = this.getControllerSlot(); - if (aGuiStack != null) { - if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { - this.mUpgraded = true; - mInventory[1] = ItemUtils.depleteStack(aGuiStack); - } - } - } - } - - @Override - public boolean canDumpFluidToME() { - // All fluids can be dumped to ME only if each layer contains a ME Output Hatch. - return this.mOutputHatchesByLayer.stream() - .allMatch( - tLayerOutputHatches -> tLayerOutputHatches.stream() - .anyMatch( - tHatch -> (tHatch instanceof GT_MetaTileEntity_Hatch_Output_ME tMEHatch) - && (tMEHatch.canAcceptFluid()))); - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - aNBT.setBoolean("mUpgraded", mUpgraded); - super.setItemNBT(aNBT); - } - - @Override - public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { - super.addAdditionalTooltipInformation(stack, tooltip); - NBTTagCompound aNBT = stack.getTagCompound(); - if (aNBT != null && aNBT.hasKey("mUpgraded")) { - tooltip.add(StatCollector.translateToLocal("tooltip.large_distill_tower.upgraded")); - } - } - - private enum Mode { - - DistillationTower(RecipeMaps.distillationTowerRecipes), - Distillery(RecipeMaps.distilleryRecipes),; - - static final Mode[] VALUES = values(); - private final RecipeMap recipeMap; - - Mode(RecipeMap recipeMap) { - this.recipeMap = recipeMap; - } - - public RecipeMap getRecipeMap() { - return recipeMap; - } - - public Mode next() { - return VALUES[(ordinal() + 1) % VALUES.length]; - } - } - - @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); - tag.setInteger("mode", mMode.ordinal()); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector - .translateToLocal("GT5U.GTPP_MULTI_ADV_DISTILLATION_TOWER.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java deleted file mode 100644 index 91a1274d69..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ /dev/null @@ -1,328 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -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.Objects; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - public static String mHotFuelName = "Blazing Pyrotheum"; - public static String mCasingName = "Volcanus Casing"; - public static String mHatchName = "Pyrotheum Hatch"; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - private int mCasing; - private final ArrayList mPyrotheumHatches = new ArrayList<>(); - - private HeatingCoilLevel mHeatingCapacity = HeatingCoilLevel.None; - - public GregtechMetaTileEntity_Adv_EBF(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); - } - - public GregtechMetaTileEntity_Adv_EBF(String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); - } - - @Override - public String getMachineType() { - return "Blast Furnace"; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_EBF(this.mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Blast Furnace") - .addInfo("Speed: +120% | EU Usage: 90% | Parallel: 8") - .addInfo("Consumes 10L of " + mHotFuelName + " per second during operation") - .addInfo("Constructed exactly the same as a normal EBF") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addController("Bottom center") - .addCasingInfoMin(mCasingName, 8, false) - .addInputHatch("Any Casing", 1) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addOtherStructurePart(mHatchName, "Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public String[] getExtraInfoData() { - return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(mHeatingCapacity.getHeat()) - + EnumChatFormatting.RESET - + " K" }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, - { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) - .adder(GregtechMetaTileEntity_Adv_EBF::addPyrotheumHatch) - .hatchId(968) - .shouldReject(x -> !x.mPyrotheumHatches.isEmpty()) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_Adv_EBF.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 11)))) - .addElement( - 'H', - ofCoil(GregtechMetaTileEntity_Adv_EBF::setCoilLevel, GregtechMetaTileEntity_Adv_EBF::getCoilLevel)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mPyrotheumHatches.clear(); - setCoilLevel(HeatingCoilLevel.None); - return checkPiece(mName, 1, 3, 0) && mCasing >= 8 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); - } - - @Override - public boolean checkHatch() { - return super.checkHatch() && !mPyrotheumHatches.isEmpty(); - } - - private boolean addPyrotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase - && aMetaTileEntity.getBaseMetaTileEntity() - .getMetaTileID() == 968) { - return addToMachineListInternal(mPyrotheumHatches, aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public void updateSlots() { - for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : filterValidMTEs(mPyrotheumHatches)) tHatch.updateSlots(); - super.updateSlots(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAAdvancedEBFActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAAdvancedEBF; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.blastFurnaceRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL - : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); - } - - @NotNull - @Override - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return super.createOverclockCalculator(recipe).setHeatOC(true) - .setHeatDiscount(true) - .setRecipeHeat(recipe.mSpecialValue) - .setMachineHeat((int) getCoilLevel().getHeat()); - } - }.setSpeedBonus(1F / 2.2F) - .setEuModifier(0.9F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvEBF; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - // Try dry Pyrotheum after all other logic - if (this.mStartUpCheck < 0) { - if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled()) { - if (aTick % 20 == 0 || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled()) { - if (!this.depleteInputFromRestrictedHatches(this.mPyrotheumHatches, 10)) { - this.causeMaintenanceIssue(); - this.stopMachine( - ShutDownReasonRegistry - .outOfFluid(Objects.requireNonNull(FluidUtils.getFluidStack("pyrotheum", 10)))); - } - } - } - } - } - - @Override - public int getMaxParallelRecipes() { - return 8; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - inputSeparation = !inputSeparation; - aPlayer.addChatMessage( - new ChatComponentTranslation( - inputSeparation ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - inputSeparation = aNBT.getBoolean("isBussesSeparate"); - } - } - - public HeatingCoilLevel getCoilLevel() { - return mHeatingCapacity; - } - - public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mHeatingCapacity = aCoilLevel; - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java deleted file mode 100644 index 11f56cbd13..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java +++ /dev/null @@ -1,200 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -import java.lang.reflect.Method; - -import net.minecraft.block.Block; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -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.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.overclockdescriber.OverclockDescriber; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.AdvancedFusionOverclockDescriber; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_FusionComputer; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer { - - public static final Method mUpdateHatchTexture; - - static { - mUpdateHatchTexture = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); - } - - public GregtechMetaTileEntity_Adv_Fusion_MK4(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_Fusion_MK4(String aName) { - super(aName); - } - - @Override - protected OverclockDescriber createOverclockDescriber() { - return new AdvancedFusionOverclockDescriber((byte) tier(), capableStartupCanonical()); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Fusion Reactor") - .addInfo("HARNESSING THE POWER OF A BLUE GIANT") - .addInfo("Controller block for the Fusion Reactor Mk IV") - .addInfo("131072EU/t and 320M EU capacity per Energy Hatch") - .addInfo("If the recipe has a startup cost greater than the") - .addInfo("number of energy hatches * cap, you can't do it") - .addInfo("Performs 4/4 overclocks") - .addSeparator() - .beginStructureBlock(15, 3, 15, false) - .addController("See diagram when placed") - .addCasingInfoMin("Fusion Machine Casings MK III", 79, false) - .addStructureInfo("Cover the coils with casing") - .addOtherStructurePart("Advanced Fusion Coils", "Center part of the ring") - .addEnergyHatch("1-16, Specified casings", 2) - .addInputHatch("2-16, Specified casings", 1) - .addOutputHatch("1-16, Specified casings", 3) - .addStructureInfo("ALL Hatches must be UHV or better") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public int tier() { - return 9; - } - - @Override - public long maxEUStore() { - return (640010000L * 4) * (Math.min(16, this.mEnergyHatches.size())) / 8L; - } - - @Override - public long capableStartupCanonical() { - return 5_120_000_000L; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_Fusion_MK4(mName); - } - - @Override - public Block getCasing() { - return getFusionCoil(); - } - - @Override - public int getCasingMeta() { - return 12; - } - - @Override - public Block getFusionCoil() { - return ModBlocks.blockCasings3Misc; - } - - @Override - public int getFusionCoilMeta() { - return 13; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return super.createProcessingLogic().enablePerfectOverclock(); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { - new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)), - TextureFactory.builder() - .addIcon(this.getIconOverlay()) - .extFacing() - .build() }; - } else if (!aActive) { - return new ITexture[] { new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; - } else { - return new ITexture[] { new GT_RenderedTexture( - TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; - } - } - - @Override - public ITexture getTextureOverlay() { - return new GT_RenderedTexture( - this.getBaseMetaTileEntity() - .isActive() ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1); - } - - public IIconContainer getIconOverlay() { - return this.getBaseMetaTileEntity() - .isActive() ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1; - } - - @Override - public boolean turnCasingActive(final boolean status) { - try { - if (this.mEnergyHatches != null) { - for (final GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { - mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch2 : this.mOutputHatches) { - mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch3 : this.mInputHatches) { - mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(2, 14) : 53)); - } - } - } catch (Throwable t) { - return false; - } - return true; - } - - @Override - public String[] getInfoData() { - String tier = "IV"; - float plasmaOut = 0; - int powerRequired = 0; - if (this.mLastRecipe != null) { - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; - } - } - - return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", - "Stored EU: " + mEUStore + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t" }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK5.java deleted file mode 100644 index 9b0dce3674..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK5.java +++ /dev/null @@ -1,200 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -import java.lang.reflect.Method; - -import net.minecraft.block.Block; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -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.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.overclockdescriber.OverclockDescriber; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.AdvancedFusionOverclockDescriber; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_FusionComputer; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Adv_Fusion_MK5 extends GT_MetaTileEntity_FusionComputer { - - public static final Method mUpdateHatchTexture; - - static { - mUpdateHatchTexture = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); - } - - public GregtechMetaTileEntity_Adv_Fusion_MK5(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_Fusion_MK5(String aName) { - super(aName); - } - - @Override - protected OverclockDescriber createOverclockDescriber() { - return new AdvancedFusionOverclockDescriber((byte) tier(), capableStartupCanonical()); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Fusion Reactor") - .addInfo("HARNESSING THE POWER OF A NEUTRON STAR") - .addInfo("Controller block for the Fusion Reactor Mk V") - .addInfo("524,288EU/t and 1.28B EU capacity per Energy Hatch") - .addInfo("If the recipe has a startup cost greater than the") - .addInfo("number of energy hatches * cap, you can't do it") - .addInfo("Performs 4/4 overclocks") - .addSeparator() - .beginStructureBlock(15, 3, 15, false) - .addController("See diagram when placed") - .addCasingInfoMin("Fusion Machine Casings MK IV", 79, false) - .addStructureInfo("Cover the coils with casing") - .addOtherStructurePart("Advanced Fusion Coils II", "Center part of the ring") - .addEnergyHatch("1-16, Specified casings", 2) - .addInputHatch("2-16, Specified casings", 1) - .addOutputHatch("1-16, Specified casings", 3) - .addStructureInfo("ALL Hatches must be UEV or better") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public int tier() { - return 10; - } - - @Override - public long maxEUStore() { - return (640010000L * 16) * (Math.min(16, this.mEnergyHatches.size())) / 8L; - } - - @Override - public long capableStartupCanonical() { - return 20_480_000_000L; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_Fusion_MK5(mName); - } - - @Override - public Block getCasing() { - return getFusionCoil(); - } - - @Override - public int getCasingMeta() { - return 0; - } - - @Override - public Block getFusionCoil() { - return ModBlocks.blockCasings6Misc; - } - - @Override - public int getFusionCoilMeta() { - return 1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return super.createProcessingLogic().enablePerfectOverclock(); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { - new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)), - TextureFactory.builder() - .addIcon(this.getIconOverlay()) - .extFacing() - .build() }; - } else if (!aActive) { - return new ITexture[] { new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; - } else { - return new ITexture[] { new GT_RenderedTexture( - TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_HYPER, - Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; - } - } - - @Override - public ITexture getTextureOverlay() { - return new GT_RenderedTexture( - this.getBaseMetaTileEntity() - .isActive() ? TexturesGtBlock.Casing_Machine_Screen_Rainbow : TexturesGtBlock.Casing_Machine_Screen_1); - } - - public IIconContainer getIconOverlay() { - return this.getBaseMetaTileEntity() - .isActive() ? TexturesGtBlock.Casing_Machine_Screen_Rainbow : TexturesGtBlock.Casing_Machine_Screen_1; - } - - @Override - public boolean turnCasingActive(final boolean status) { - try { - if (this.mEnergyHatches != null) { - for (final GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { - mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(3, 6) : 53)); - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch2 : this.mOutputHatches) { - mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(3, 6) : 53)); - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch3 : this.mInputHatches) { - mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(3, 6) : 53)); - } - } - } catch (Throwable t) { - return false; - } - return true; - } - - @Override - public String[] getInfoData() { - String tier = "V"; - float plasmaOut = 0; - int powerRequired = 0; - if (this.mLastRecipe != null) { - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; - } - } - - return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", - "Stored EU: " + mEUStore + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t" }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java deleted file mode 100644 index f8579957f3..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java +++ /dev/null @@ -1,409 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -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 net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gregtech.api.registries.LHECoolantRegistry; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; -import gtPlusPlus.core.block.base.BlockBaseModular; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.ALLOY; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Adv_HeatExchanger - extends GregtechMeta_MultiBlockBase { - - private static final int CASING_INDEX = TAE.getIndexFromPage(1, 12); - private static final String STRUCTURE_PIECE_MAIN = "main"; - - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition - .builder() - .addShape( - STRUCTURE_PIECE_MAIN, - transpose( - new String[][] { { " ccc ", "cCCCc", "cCCCc", "cCCCc", " ccc " }, - { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, - { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, - { " c~c ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " hhh ", "hHHHh", "hHHHh", "hHHHh", " hhh " }, - { " f f ", "f f", " ", "f f", " f f " }, - { " f f ", "f f", " ", "f f", " f f " }, })) - .addElement('P', ofBlock(GregTech_API.sBlockCasings2, 15)) - .addElement('f', ofBlock(getFrame(), 0)) - .addElement( - 'C', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_Adv_HeatExchanger::addColdFluidOutputToMachineList, - CASING_INDEX, - 2), - onElementPass( - GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, - ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) - .addElement( - 'H', - ofChain( - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addHotFluidInputToMachineList, CASING_INDEX, 3), - onElementPass( - GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, - ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) - .addElement( - 'h', - ofChain( - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addOutputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GregtechMetaTileEntity_Adv_HeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), - onElementPass( - GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, - ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) - .addElement( - 'c', - ofChain( - onElementPass( - GregtechMetaTileEntity_Adv_HeatExchanger::onCasingAdded, - ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) - .build(); - public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) - - private GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; - private GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; - private boolean superheated = false; - private int superheated_threshold = 0; - private float water; - private int mCasingAmount; - - public GregtechMetaTileEntity_Adv_HeatExchanger(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_HeatExchanger(String aName) { - super(aName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the XL Heat Exchanger") - .addInfo("More complicated than a Fusion Reactor. Seriously") - .addInfo("But you know this by now, right?") - .addInfo("Works as fast as 32 Large Heat Exchangers") - .addSeparator() - .addInfo("Inputs are Hot Coolant or Lava") - .addInfo("Outputs Coolant or Pahoehoe Lava and SH Steam/Steam") - .addInfo("Outputs SH Steam if input flow is equal to or above a certain value:") - .addInfo("Hot Coolant: 25,600 L/s, maximum 51,200 L/s, max output 10,240,000 SH Steam/s") - .addInfo("Lava: 32,000 L/s, maximum 64,000 L/s, max output 5,120,000 SH Steam/s") - .addInfo("A circuit in the controller lowers the SH Steam threshold and efficiency") - .addInfo("3.75% reduction and 1.5% efficiency loss per circuit config over 1") - .addSeparator() - .beginStructureBlock(5, 9, 5, false) - .addController("Front bottom") - .addCasingInfoMin("Reinforced Heat Exchanger Casing", 90, false) - .addOtherStructurePart("Tungstensteel Pipe Casing", "Center 3x5x3 (45 blocks)") - .addMaintenanceHatch("Any casing", 1) - .addInputHatch("Hot fluid, bottom center", 2) - .addInputHatch("Distilled water, any bottom layer casing", 1) - .addOutputHatch("Cold fluid, top center", 3) - .addOutputHatch("Steam/SH Steam, any bottom layer casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - superheated = aNBT.getBoolean("superheated"); - super.loadNBTData(aNBT); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("superheated", superheated); - super.saveNBTData(aNBT); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAAdvancedHeatExchangerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAAdvancedHeatExchanger; - } - - @Override - protected int getCasingTextureId() { - return CASING_INDEX; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> !r.isUpsideDown() && !f.isVerticallyFliped(); - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - if (mInputHotFluidHatch.getFluid() == null) return CheckRecipeResultRegistry.SUCCESSFUL; - - int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch - - // The XL LHE works as fast as 32 regular LHEs. These are the comments from the original LHE, - // with changes where the values needed to change for the 32x speed multiplier - superheated_threshold = 128000; // default: must have 4000L -> 128000L per second to generate superheated steam - float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry - int shs_reduction_per_config = 4800; // reduce threshold 150L -> 4800L per second per circuitry level (1-25) - float steam_output_multiplier = 20f; // default: multiply output by 4 * 10 (boosted x5) - float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). - - // Do we have an integrated circuit with a valid configuration? - if (mInventory[1] != null && mInventory[1].getUnlocalizedName() - .startsWith("gt.integrated_circuit")) { - int circuit_config = mInventory[1].getItemDamage(); - if (circuit_config >= 1 && circuit_config <= 25) { - // If so, apply the penalty and reduced threshold. - penalty = (circuit_config - 1) * penalty_per_config; - superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1)); - } - } - - efficiency -= penalty; - - var coolant = LHECoolantRegistry.getCoolant( - mInputHotFluidHatch.getFluid() - .getFluid()); - - if (coolant == null) { - superheated_threshold = 0; - return CheckRecipeResultRegistry.NO_RECIPE; - } else { - steam_output_multiplier *= coolant.steamMultiplier; - superheated_threshold *= coolant.superheatedThreshold; - } - - // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. - this.superheated = fluidAmountToConsume >= superheated_threshold; - - // Don't consume too much hot fluid per second, maximum is 2x SH threshold. - fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); - - mInputHotFluidHatch.drain(fluidAmountToConsume, true); - mOutputColdFluidHatch.fill(coolant.getColdFluid(fluidAmountToConsume), true); - - this.mMaxProgresstime = 20; - this.lEUt = (long) (fluidAmountToConsume * steam_output_multiplier * efficiency); - this.mEfficiencyIncrease = 80; - - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - private int useWater(float input) { - water = water + input; - int usage = (int) water; - water = water - usage; - return usage; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (this.lEUt > 0) { - int tGeneratedEU = (int) (this.lEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to - // generate. - if (tGeneratedEU > 0) { - - if (superheated) tGeneratedEU /= 2; // We produce half as much superheated steam if necessary - - int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume - // tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect - // 1:160 ratio with distilled water consumption - - FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed); - if (depleteInput(distilledStack)) // Consume the distilled water - { - if (superheated) { - addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate - // superheated - // steam - } else { - addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam - } - } else { - GT_Log.exp.println(this.mName + " had no more Distilled water!"); - explodeMultiblock(); // Generate crater - } - } - return true; - } - return true; - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; - } - - private void onCasingAdded() { - mCasingAmount++; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mOutputColdFluidHatch = null; - mInputHotFluidHatch = null; - mCasingAmount = 0; - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 5, 0) && mCasingAmount >= 90 && mMaintenanceHatches.size() == 1; - } - - public boolean addColdFluidOutputToMachineList(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); - mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; - return true; - } - return false; - } - - public boolean addHotFluidInputToMachineList(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) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); - mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; - return true; - } - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_HeatExchanger(this.mName); - } - - @Override - public boolean isGivingInformation() { - return super.isGivingInformation(); - } - - @Override - public String[] getExtraInfoData() { - return new String[] { - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(mProgresstime / 20) - + EnumChatFormatting.RESET - + " s / " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(mMaxProgresstime / 20) - + EnumChatFormatting.RESET - + " s", - StatCollector.translateToLocal("GT5U.multiblock.usage") + " " - + StatCollector.translateToLocal("GT5U.LHE.steam") - + ": " - + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) - + GT_Utility.formatNumbers(superheated ? -2 * lEUt : -lEUt) - + EnumChatFormatting.RESET - + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " - + EnumChatFormatting.RED - + (getIdealStatus() - getRepairStatus()) - + EnumChatFormatting.RESET - + " " - + StatCollector.translateToLocal("GT5U.multiblock.efficiency") - + ": " - + EnumChatFormatting.YELLOW - + mEfficiency / 100.0F - + EnumChatFormatting.RESET - + " %", - StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " - + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) - + superheated - + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.LHE.superheated") + " " - + StatCollector.translateToLocal("GT5U.LHE.threshold") - + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(superheated_threshold) - + EnumChatFormatting.RESET }; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 5, 0); - } - - @Override - public String getMachineType() { - return "Heat Exchanger"; - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - private static Block sFrame; - - public static Block getFrame() { - if (sFrame == null) { - sFrame = BlockBaseModular.getMaterialBlock(ALLOY.TALONITE, BlockTypes.FRAME); - } - return sFrame; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java deleted file mode 100644 index a2bb155809..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java +++ /dev/null @@ -1,177 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; - -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.GregTech_API.sBlockCasings4; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.InputBus; -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.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.item.ItemStack; - -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import gregtech.api.enums.SoundResource; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Adv_Implosion - extends GregtechMeta_MultiBlockBase { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Adv_Implosion(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Adv_Implosion(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Adv_Implosion(this.mName); - } - - @Override - public String getMachineType() { - return "Implosion Compressor"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Factory Grade Advanced Implosion Compressor") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: ((Tier/2)+1)") - .addInfo("Constructed exactly the same as a normal Implosion Compressor") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfoMin("Robust TungstenSteel Casing", 10, false) - .addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Adv_Implosion.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(48) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(sBlockCasings4, 0)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAAdvancedImplosionActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAAdvancedImplosion; - } - - @Override - protected int getCasingTextureId() { - return 48; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.implosionRecipes; - } - - @Override - public int getRecipeCatalystPriority() { - return -1; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.RANDOM_EXPLODE; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return (GT_Utility.getTier(this.getMaxInputVoltage()) / 2 + 1); - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java new file mode 100644 index 0000000000..ad351caf55 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java @@ -0,0 +1,504 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +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 net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.IIconContainer; +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.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.MTEHatchOutputME; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEAdvDistillationTower extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private Mode mMode = Mode.DistillationTower; + private boolean mUpgraded = false; + + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; + + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEAdvDistillationTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAdvDistillationTower(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvDistillationTower(this.mName); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + IHatchElement layeredOutputHatch = OutputHatch + .withCount(MTEAdvDistillationTower::getCurrentLayerOutputHatchCount) + .withAdder(MTEAdvDistillationTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" }, })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "lll", "lcl", "lll" }, })) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][] { { "lll", "l-l", "lll" }, })) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][] { { "ttt", "ttt", "ttt" }, })) + .addElement( + 'b', + ofChain( + buildHatchAdder(MTEAdvDistillationTower.class) + .atLeast(Energy, OutputBus, InputHatch, InputBus, Maintenance) + .disallowOnly(ForgeDirection.UP) + .casingIndex(getCasingTextureId()) + .dot(1) + .build(), + ofBlock(GregTechAPI.sBlockCasings4, 1))) + .addElement( + 'l', + ofChain( + buildHatchAdder(MTEAdvDistillationTower.class).atLeast(layeredOutputHatch, Energy, Maintenance) + .disallowOnly(ForgeDirection.UP, ForgeDirection.DOWN) + .casingIndex(getCasingTextureId()) + .dot(2) + .build(), + ofHatchAdder(MTEAdvDistillationTower::addMufflerToMachineList, getCasingTextureId(), 3), + ofBlock(GregTechAPI.sBlockCasings4, 1))) + .addElement( + 'c', + ofChain( + onElementPass( + MTEAdvDistillationTower::onTopLayerFound, + ofHatchAdder(MTEAdvDistillationTower::addMufflerToMachineList, getCasingTextureId(), 3)), + onElementPass( + MTEAdvDistillationTower::onTopLayerFound, + ofHatchAdder(MTEAdvDistillationTower::addOutputToMachineList, getCasingTextureId(), 3)), + onElementPass( + MTEAdvDistillationTower::onTopLayerFound, + ofHatchAdder( + MTEAdvDistillationTower::addMaintenanceToMachineList, + getCasingTextureId(), + 3)), + onElementPass(MTEAdvDistillationTower::onTopLayerFound, ofBlock(GregTechAPI.sBlockCasings4, 1)), + isAir())) + .addElement( + 't', + buildHatchAdder(MTEAdvDistillationTower.class).atLeast(layeredOutputHatch, Muffler) + .disallowOnly(ForgeDirection.DOWN) + .casingIndex(getCasingTextureId()) + .dot(2) + .buildAndChain(GregTechAPI.sBlockCasings4, 1)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + protected int getCurrentLayerOutputHatchCount() { + return mOutputHatchesByLayer.size() < mHeight || mHeight <= 0 ? 0 + : mOutputHatchesByLayer.get(mHeight - 1) + .size(); + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null || aTileEntity.isDead() + || !(aTileEntity.getMetaTileEntity() instanceof MTEHatchOutput tHatch)) return false; + while (mOutputHatchesByLayer.size() < mHeight) mOutputHatchesByLayer.add(new ArrayList<>()); + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatchesByLayer.get(mHeight - 1) + .add(tHatch) && mOutputHatches.add(tHatch); + } + + protected void onTopLayerFound() { + mTopLayerFound = true; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Advanced Distillation Tower") + .addInfo("Use 85% less energy in distillery mode") + .addInfo("250%/100% faster in DT/distillery mode") + .addInfo("Right click the controller with screwdriver to change mode.") + .addInfo("Max parallel dictated by tower tier and mode") + .addInfo("DTower Mode: T1=4, T2=12") + .addInfo("Distillery Mode: Tower Tier * (4*InputTier)") + .addInfo("Distillery Mode require a full height tower") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfoMin("Clean Stainless Steel Machine Casing", 7, false) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addOutputHatch("One per layer except bottom", 2) + .addMufflerHatch("Top Casing", 3) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); + } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + mHeight = 0; + int built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 1, 0, 0, elementBudget, env, false, true); + if (built >= 0) return built; + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + mHeight = i; + built = survivialBuildPiece( + STRUCTURE_PIECE_LAYER_HINT, + stackSize, + 1, + i, + 0, + elementBudget, + env, + false, + true); + if (built >= 0) return built; + } + mHeight = tTotalHeight - 1; + return survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, + stackSize, + 1, + tTotalHeight - 1, + 0, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) return false; + + // check each layer + while (mHeight < 12) { + if (!checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) { + return false; + } + if (mOutputHatchesByLayer.size() < mHeight || mOutputHatchesByLayer.get(mHeight - 1) + .isEmpty()) + // layer without output hatch + return false; + if (mTopLayerFound || !mMufflerHatches.isEmpty()) { + break; + } + // not top + mHeight++; + } + boolean check = mTopLayerFound && mHeight >= 2 && checkHatch(); + if (check && mHeight < 11) { + // force the mode to DT if not in full height + mMode = Mode.DistillationTower; + mLastRecipe = null; + } + return check; + } + + @Override + public RecipeMap getRecipeMap() { + return mMode.getRecipeMap(); + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.distilleryRecipes, RecipeMaps.distillationTowerRecipes); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + if (this.mMode == Mode.Distillery) + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMode", (byte) mMode.ordinal()); + aNBT.setBoolean("mUpgraded", mUpgraded); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mMode = Mode.values()[aNBT.getByte("mMode")]; + mUpgraded = aNBT.getBoolean("mUpgraded"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mHeight < 11) { + PlayerUtils.messagePlayer(aPlayer, "Cannot switch mode if not in full height."); + return; + } + mMode = mMode.next(); + PlayerUtils.messagePlayer(aPlayer, "Now running in " + mMode + " Mode."); + mLastRecipe = null; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack copiedFluidStack = aLiquid.copy(); + for (List hatches : mOutputHatchesByLayer) { + if (dumpFluid(hatches, copiedFluidStack, true)) return true; + } + for (List hatches : mOutputHatchesByLayer) { + if (dumpFluid(hatches, copiedFluidStack, false)) return true; + } + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + if (mMode == Mode.DistillationTower) { + // dt mode + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i].copy(); + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } else { + // distillery mode + for (FluidStack outputFluidStack : mOutputFluids2) { + addOutput(outputFluidStack); + } + } + } + + @Override + public List getFluidOutputSlots(FluidStack[] toOutput) { + return getFluidOutputSlotsByLayer(toOutput, mOutputHatchesByLayer); + } + + @Override + public String getMachineType() { + return "Distillery, Distillation Tower"; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setEuModifier(mMode == Mode.Distillery ? 0.15F : 1F); + logic.setSpeedBonus(mMode == Mode.Distillery ? 1F / 2F : 1F / 3.5F); + } + + @Override + public int getMaxParallelRecipes() { + return switch (mMode) { + case DistillationTower -> getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0; + case Distillery -> getTierOfTower() * (4 * GTUtility.getTier(this.getMaxInputVoltage())); + default -> 0; + }; + } + + private int getTierOfTower() { + return mUpgraded ? 2 : 1; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; + } + + @Override + protected int getCasingTextureId() { + return 49; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aTick % 20 == 0 && !mUpgraded) { + ItemStack aGuiStack = this.getControllerSlot(); + if (aGuiStack != null) { + if (GTUtility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { + this.mUpgraded = true; + mInventory[1] = ItemUtils.depleteStack(aGuiStack); + } + } + } + } + + @Override + public boolean canDumpFluidToME() { + // All fluids can be dumped to ME only if each layer contains a ME Output Hatch. + return this.mOutputHatchesByLayer.stream() + .allMatch( + tLayerOutputHatches -> tLayerOutputHatches.stream() + .anyMatch(tHatch -> (tHatch instanceof MTEHatchOutputME tMEHatch) && (tMEHatch.canAcceptFluid()))); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setBoolean("mUpgraded", mUpgraded); + super.setItemNBT(aNBT); + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + super.addAdditionalTooltipInformation(stack, tooltip); + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null && aNBT.hasKey("mUpgraded")) { + tooltip.add(StatCollector.translateToLocal("tooltip.large_distill_tower.upgraded")); + } + } + + private enum Mode { + + DistillationTower(RecipeMaps.distillationTowerRecipes), + Distillery(RecipeMaps.distilleryRecipes),; + + static final Mode[] VALUES = values(); + private final RecipeMap recipeMap; + + Mode(RecipeMap recipeMap) { + this.recipeMap = recipeMap; + } + + public RecipeMap getRecipeMap() { + return recipeMap; + } + + public Mode next() { + return VALUES[(ordinal() + 1) % VALUES.length]; + } + } + + @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); + tag.setInteger("mode", mMode.ordinal()); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector + .translateToLocal("GT5U.GTPP_MULTI_ADV_DISTILLATION_TOWER.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvEBF.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvEBF.java new file mode 100644 index 0000000000..63aec37990 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvEBF.java @@ -0,0 +1,323 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +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.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTEHatchCustomFluidBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAdvEBF extends GTPPMultiBlockBase implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + public static String mHotFuelName = "Blazing Pyrotheum"; + public static String mCasingName = "Volcanus Casing"; + public static String mHatchName = "Pyrotheum Hatch"; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + private int mCasing; + private final ArrayList mPyrotheumHatches = new ArrayList<>(); + + private HeatingCoilLevel mHeatingCapacity = HeatingCoilLevel.None; + + public MTEAdvEBF(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + } + + public MTEAdvEBF(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + } + + @Override + public String getMachineType() { + return "Blast Furnace"; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvEBF(this.mName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Blast Furnace") + .addInfo("Speed: +120% | EU Usage: 90% | Parallel: 8") + .addInfo("Consumes 10L of " + mHotFuelName + " per second during operation") + .addInfo("Constructed exactly the same as a normal EBF") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Bottom center") + .addCasingInfoMin(mCasingName, 8, false) + .addInputHatch("Any Casing", 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addOtherStructurePart(mHatchName, "Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(mHeatingCapacity.getHeat()) + + EnumChatFormatting.RESET + + " K" }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, + { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEAdvEBF.class).adder(MTEAdvEBF::addPyrotheumHatch) + .hatchId(968) + .shouldReject(x -> !x.mPyrotheumHatches.isEmpty()) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + buildHatchAdder(MTEAdvEBF.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 11)))) + .addElement('H', ofCoil(MTEAdvEBF::setCoilLevel, MTEAdvEBF::getCoilLevel)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mPyrotheumHatches.clear(); + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 3, 0) && mCasing >= 8 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && !mPyrotheumHatches.isEmpty(); + } + + private boolean addPyrotheumHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchCustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity() + .getMetaTileID() == 968) { + return addToMachineListInternal(mPyrotheumHatches, aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void updateSlots() { + for (MTEHatchCustomFluidBase tHatch : filterValidMTEs(mPyrotheumHatches)) tHatch.updateSlots(); + super.updateSlots(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAAdvancedEBFActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAAdvancedEBF; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.blastFurnaceRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setHeatOC(true) + .setHeatDiscount(true) + .setRecipeHeat(recipe.mSpecialValue) + .setMachineHeat((int) getCoilLevel().getHeat()); + } + }.setSpeedBonus(1F / 2.2F) + .setEuModifier(0.9F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAdvEBF; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Try dry Pyrotheum after all other logic + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled()) { + if (aTick % 20 == 0 || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled()) { + if (!this.depleteInputFromRestrictedHatches(this.mPyrotheumHatches, 10)) { + this.causeMaintenanceIssue(); + this.stopMachine( + ShutDownReasonRegistry + .outOfFluid(Objects.requireNonNull(FluidUtils.getFluidStack("pyrotheum", 10)))); + } + } + } + } + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + aPlayer.addChatMessage( + new ChatComponentTranslation( + inputSeparation ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk4.java new file mode 100644 index 0000000000..eed5159271 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk4.java @@ -0,0 +1,200 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import java.lang.reflect.Method; + +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.objects.overclockdescriber.OverclockDescriber; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.AdvancedFusionOverclockDescriber; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.multi.MTEFusionComputer; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAdvFusionMk4 extends MTEFusionComputer { + + public static final Method mUpdateHatchTexture; + + static { + mUpdateHatchTexture = ReflectionUtils.getMethod(MTEHatch.class, "updateTexture", int.class); + } + + public MTEAdvFusionMk4(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAdvFusionMk4(String aName) { + super(aName); + } + + @Override + protected OverclockDescriber createOverclockDescriber() { + return new AdvancedFusionOverclockDescriber((byte) tier(), capableStartupCanonical()); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Fusion Reactor") + .addInfo("HARNESSING THE POWER OF A BLUE GIANT") + .addInfo("Controller block for the Fusion Reactor Mk IV") + .addInfo("131072EU/t and 320M EU capacity per Energy Hatch") + .addInfo("If the recipe has a startup cost greater than the") + .addInfo("number of energy hatches * cap, you can't do it") + .addInfo("Performs 4/4 overclocks") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfoMin("Fusion Machine Casings MK III", 79, false) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Advanced Fusion Coils", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) + .addStructureInfo("ALL Hatches must be UHV or better") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public int tier() { + return 9; + } + + @Override + public long maxEUStore() { + return (640010000L * 4) * (Math.min(16, this.mEnergyHatches.size())) / 8L; + } + + @Override + public long capableStartupCanonical() { + return 5_120_000_000L; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvFusionMk4(mName); + } + + @Override + public Block getCasing() { + return getFusionCoil(); + } + + @Override + public int getCasingMeta() { + return 12; + } + + @Override + public Block getFusionCoil() { + return ModBlocks.blockCasings3Misc; + } + + @Override + public int getFusionCoilMeta() { + return 13; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return super.createProcessingLogic().enablePerfectOverclock(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { + new GTRenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)), + TextureFactory.builder() + .addIcon(this.getIconOverlay()) + .extFacing() + .build() }; + } else if (!aActive) { + return new ITexture[] { new GTRenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; + } else { + return new ITexture[] { new GTRenderedTexture( + TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; + } + } + + @Override + public ITexture getTextureOverlay() { + return new GTRenderedTexture( + this.getBaseMetaTileEntity() + .isActive() ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1); + } + + public IIconContainer getIconOverlay() { + return this.getBaseMetaTileEntity() + .isActive() ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1; + } + + @Override + public boolean turnCasingActive(final boolean status) { + try { + if (this.mEnergyHatches != null) { + for (final MTEHatchEnergy hatch : this.mEnergyHatches) { + mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mOutputHatches != null) { + for (final MTEHatchOutput hatch2 : this.mOutputHatches) { + mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mInputHatches != null) { + for (final MTEHatchInput hatch3 : this.mInputHatches) { + mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + } catch (Throwable t) { + return false; + } + return true; + } + + @Override + public String[] getInfoData() { + String tier = "IV"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + mEUStore + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t" }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk5.java new file mode 100644 index 0000000000..9ed65ffa08 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvFusionMk5.java @@ -0,0 +1,200 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import java.lang.reflect.Method; + +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.objects.overclockdescriber.OverclockDescriber; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.AdvancedFusionOverclockDescriber; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.multi.MTEFusionComputer; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAdvFusionMk5 extends MTEFusionComputer { + + public static final Method mUpdateHatchTexture; + + static { + mUpdateHatchTexture = ReflectionUtils.getMethod(MTEHatch.class, "updateTexture", int.class); + } + + public MTEAdvFusionMk5(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAdvFusionMk5(String aName) { + super(aName); + } + + @Override + protected OverclockDescriber createOverclockDescriber() { + return new AdvancedFusionOverclockDescriber((byte) tier(), capableStartupCanonical()); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Fusion Reactor") + .addInfo("HARNESSING THE POWER OF A NEUTRON STAR") + .addInfo("Controller block for the Fusion Reactor Mk V") + .addInfo("524,288EU/t and 1.28B EU capacity per Energy Hatch") + .addInfo("If the recipe has a startup cost greater than the") + .addInfo("number of energy hatches * cap, you can't do it") + .addInfo("Performs 4/4 overclocks") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfoMin("Fusion Machine Casings MK IV", 79, false) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Advanced Fusion Coils II", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) + .addStructureInfo("ALL Hatches must be UEV or better") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public int tier() { + return 10; + } + + @Override + public long maxEUStore() { + return (640010000L * 16) * (Math.min(16, this.mEnergyHatches.size())) / 8L; + } + + @Override + public long capableStartupCanonical() { + return 20_480_000_000L; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvFusionMk5(mName); + } + + @Override + public Block getCasing() { + return getFusionCoil(); + } + + @Override + public int getCasingMeta() { + return 0; + } + + @Override + public Block getFusionCoil() { + return ModBlocks.blockCasings6Misc; + } + + @Override + public int getFusionCoilMeta() { + return 1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return super.createProcessingLogic().enablePerfectOverclock(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { + new GTRenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)), + TextureFactory.builder() + .addIcon(this.getIconOverlay()) + .extFacing() + .build() }; + } else if (!aActive) { + return new ITexture[] { new GTRenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; + } else { + return new ITexture[] { new GTRenderedTexture( + TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_HYPER, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)) }; + } + } + + @Override + public ITexture getTextureOverlay() { + return new GTRenderedTexture( + this.getBaseMetaTileEntity() + .isActive() ? TexturesGtBlock.Casing_Machine_Screen_Rainbow : TexturesGtBlock.Casing_Machine_Screen_1); + } + + public IIconContainer getIconOverlay() { + return this.getBaseMetaTileEntity() + .isActive() ? TexturesGtBlock.Casing_Machine_Screen_Rainbow : TexturesGtBlock.Casing_Machine_Screen_1; + } + + @Override + public boolean turnCasingActive(final boolean status) { + try { + if (this.mEnergyHatches != null) { + for (final MTEHatchEnergy hatch : this.mEnergyHatches) { + mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(3, 6) : 53)); + } + } + if (this.mOutputHatches != null) { + for (final MTEHatchOutput hatch2 : this.mOutputHatches) { + mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(3, 6) : 53)); + } + } + if (this.mInputHatches != null) { + for (final MTEHatchInput hatch3 : this.mInputHatches) { + mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(3, 6) : 53)); + } + } + } catch (Throwable t) { + return false; + } + return true; + } + + @Override + public String[] getInfoData() { + String tier = "V"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + mEUStore + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t" }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java new file mode 100644 index 0000000000..0779c03183 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java @@ -0,0 +1,396 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +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.GTStructureUtility.ofHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.registries.LHECoolantRegistry; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.material.MaterialsAlloy; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAdvHeatExchanger extends GTPPMultiBlockBase { + + private static final int CASING_INDEX = TAE.getIndexFromPage(1, 12); + private static final String STRUCTURE_PIECE_MAIN = "main"; + + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { " ccc ", "cCCCc", "cCCCc", "cCCCc", " ccc " }, + { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, + { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " ccc ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, + { " c~c ", "cPPPc", "cPPPc", "cPPPc", " ccc " }, { " hhh ", "hHHHh", "hHHHh", "hHHHh", " hhh " }, + { " f f ", "f f", " ", "f f", " f f " }, + { " f f ", "f f", " ", "f f", " f f " }, })) + .addElement('P', ofBlock(GregTechAPI.sBlockCasings2, 15)) + .addElement('f', ofBlock(getFrame(), 0)) + .addElement( + 'C', + ofChain( + ofHatchAdder(MTEAdvHeatExchanger::addColdFluidOutputToMachineList, CASING_INDEX, 2), + onElementPass(MTEAdvHeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'H', + ofChain( + ofHatchAdder(MTEAdvHeatExchanger::addHotFluidInputToMachineList, CASING_INDEX, 3), + onElementPass(MTEAdvHeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'h', + ofChain( + ofHatchAdder(MTEAdvHeatExchanger::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEAdvHeatExchanger::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEAdvHeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(MTEAdvHeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .addElement( + 'c', + ofChain(onElementPass(MTEAdvHeatExchanger::onCasingAdded, ofBlock(ModBlocks.blockSpecialMultiCasings, 14)))) + .build(); + public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) + + private MTEHatchInput mInputHotFluidHatch; + private MTEHatchOutput mOutputColdFluidHatch; + private boolean superheated = false; + private int superheated_threshold = 0; + private float water; + private int mCasingAmount; + + public MTEAdvHeatExchanger(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAdvHeatExchanger(String aName) { + super(aName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the XL Heat Exchanger") + .addInfo("More complicated than a Fusion Reactor. Seriously") + .addInfo("But you know this by now, right?") + .addInfo("Works as fast as 32 Large Heat Exchangers") + .addSeparator() + .addInfo("Inputs are Hot Coolant or Lava") + .addInfo("Outputs Coolant or Pahoehoe Lava and SH Steam/Steam") + .addInfo("Outputs SH Steam if input flow is equal to or above a certain value:") + .addInfo("Hot Coolant: 25,600 L/s, maximum 51,200 L/s, max output 10,240,000 SH Steam/s") + .addInfo("Lava: 32,000 L/s, maximum 64,000 L/s, max output 5,120,000 SH Steam/s") + .addInfo("A circuit in the controller lowers the SH Steam threshold and efficiency") + .addInfo("3.75% reduction and 1.5% efficiency loss per circuit config over 1") + .addSeparator() + .beginStructureBlock(5, 9, 5, false) + .addController("Front bottom") + .addCasingInfoMin("Reinforced Heat Exchanger Casing", 90, false) + .addOtherStructurePart("Tungstensteel Pipe Casing", "Center 3x5x3 (45 blocks)") + .addMaintenanceHatch("Any casing", 1) + .addInputHatch("Hot fluid, bottom center", 2) + .addInputHatch("Distilled water, any bottom layer casing", 1) + .addOutputHatch("Cold fluid, top center", 3) + .addOutputHatch("Steam/SH Steam, any bottom layer casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + superheated = aNBT.getBoolean("superheated"); + super.loadNBTData(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("superheated", superheated); + super.saveNBTData(aNBT); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAAdvancedHeatExchangerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAAdvancedHeatExchanger; + } + + @Override + protected int getCasingTextureId() { + return CASING_INDEX; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> !r.isUpsideDown() && !f.isVerticallyFliped(); + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + if (mInputHotFluidHatch.getFluid() == null) return CheckRecipeResultRegistry.SUCCESSFUL; + + int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch + + // The XL LHE works as fast as 32 regular LHEs. These are the comments from the original LHE, + // with changes where the values needed to change for the 32x speed multiplier + superheated_threshold = 128000; // default: must have 4000L -> 128000L per second to generate superheated steam + float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry + int shs_reduction_per_config = 4800; // reduce threshold 150L -> 4800L per second per circuitry level (1-25) + float steam_output_multiplier = 20f; // default: multiply output by 4 * 10 (boosted x5) + float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). + + // Do we have an integrated circuit with a valid configuration? + if (mInventory[1] != null && mInventory[1].getUnlocalizedName() + .startsWith("gt.integrated_circuit")) { + int circuit_config = mInventory[1].getItemDamage(); + if (circuit_config >= 1 && circuit_config <= 25) { + // If so, apply the penalty and reduced threshold. + penalty = (circuit_config - 1) * penalty_per_config; + superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1)); + } + } + + efficiency -= penalty; + + var coolant = LHECoolantRegistry.getCoolant( + mInputHotFluidHatch.getFluid() + .getFluid()); + + if (coolant == null) { + superheated_threshold = 0; + return CheckRecipeResultRegistry.NO_RECIPE; + } else { + steam_output_multiplier *= coolant.steamMultiplier; + superheated_threshold *= coolant.superheatedThreshold; + } + + // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. + this.superheated = fluidAmountToConsume >= superheated_threshold; + + // Don't consume too much hot fluid per second, maximum is 2x SH threshold. + fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); + + mInputHotFluidHatch.drain(fluidAmountToConsume, true); + mOutputColdFluidHatch.fill(coolant.getColdFluid(fluidAmountToConsume), true); + + this.mMaxProgresstime = 20; + this.lEUt = (long) (fluidAmountToConsume * steam_output_multiplier * efficiency); + this.mEfficiencyIncrease = 80; + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + private int useWater(float input) { + water = water + input; + int usage = (int) water; + water = water - usage; + return usage; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.lEUt > 0) { + int tGeneratedEU = (int) (this.lEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to + // generate. + if (tGeneratedEU > 0) { + + if (superheated) tGeneratedEU /= 2; // We produce half as much superheated steam if necessary + + int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume + // tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect + // 1:160 ratio with distilled water consumption + + FluidStack distilledStack = GTModHandler.getDistilledWater(distilledConsumed); + if (depleteInput(distilledStack)) // Consume the distilled water + { + if (superheated) { + addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate + // superheated + // steam + } else { + addOutput(GTModHandler.getSteam(tGeneratedEU)); // Generate regular steam + } + } else { + GTLog.exp.println(this.mName + " had no more Distilled water!"); + explodeMultiblock(); // Generate crater + } + } + return true; + } + return true; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + private void onCasingAdded() { + mCasingAmount++; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mOutputColdFluidHatch = null; + mInputHotFluidHatch = null; + mCasingAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 5, 0) && mCasingAmount >= 90 && mMaintenanceHatches.size() == 1; + } + + public boolean addColdFluidOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + mOutputColdFluidHatch = (MTEHatchOutput) aMetaTileEntity; + return true; + } + return false; + } + + public boolean addHotFluidInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = getRecipeMap(); + mInputHotFluidHatch = (MTEHatchInput) aMetaTileEntity; + return true; + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvHeatExchanger(this.mName); + } + + @Override + public boolean isGivingInformation() { + return super.isGivingInformation(); + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(mProgresstime / 20) + + EnumChatFormatting.RESET + + " s / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(mMaxProgresstime / 20) + + EnumChatFormatting.RESET + + " s", + StatCollector.translateToLocal("GT5U.multiblock.usage") + " " + + StatCollector.translateToLocal("GT5U.LHE.steam") + + ": " + + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + + GTUtility.formatNumbers(superheated ? -2 * lEUt : -lEUt) + + EnumChatFormatting.RESET + + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + + EnumChatFormatting.RESET + + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + + ": " + + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + + superheated + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + + StatCollector.translateToLocal("GT5U.LHE.threshold") + + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(superheated_threshold) + + EnumChatFormatting.RESET }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 5, 0); + } + + @Override + public String getMachineType() { + return "Heat Exchanger"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + private static Block sFrame; + + public static Block getFrame() { + if (sFrame == null) { + sFrame = BlockBaseModular.getMaterialBlock(MaterialsAlloy.TALONITE, BlockTypes.FRAME); + } + return sFrame; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvImplosionCompressor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvImplosionCompressor.java new file mode 100644 index 0000000000..109022932d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvImplosionCompressor.java @@ -0,0 +1,176 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +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.GregTechAPI.sBlockCasings4; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.item.ItemStack; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.enums.SoundResource; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAdvImplosionCompressor extends GTPPMultiBlockBase { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEAdvImplosionCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAdvImplosionCompressor(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEAdvImplosionCompressor(this.mName); + } + + @Override + public String getMachineType() { + return "Implosion Compressor"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Implosion Compressor") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: ((Tier/2)+1)") + .addInfo("Constructed exactly the same as a normal Implosion Compressor") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfoMin("Robust TungstenSteel Casing", 10, false) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEAdvImplosionCompressor.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(48) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(sBlockCasings4, 0)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAAdvancedImplosionActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAAdvancedImplosion; + } + + @Override + protected int getCasingTextureId() { + return 48; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.implosionRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.RANDOM_EXPLODE; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (GTUtility.getTier(this.getMaxInputVoltage()) / 2 + 1); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCentrifuge.java deleted file mode 100644 index 644893964b..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCentrifuge.java +++ /dev/null @@ -1,419 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.GregTech_API.*; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.enums.GT_Values.AuthorEvgenWarGold; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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.ResourceLocation; -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.google.common.collect.ImmutableList; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -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.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamCentrifuge - extends GregtechMeta_SteamMultiBase implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamCentrifuge(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamCentrifuge(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SteamCentrifuge(this.mName); - } - - @Override - public String getMachineType() { - return "Centrifuge"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - // spotless:off - private final String[][] shape = new String[][] { - { " AAA ", "AAAAA", "AAAAA", "AAAAA", " AAA " }, - { " ", " ABA ", " BDB ", " ABA ", " " }, - { " A ", " ACA ", "ACDCA", " ACA ", " A " }, - { " A~A ", "AABAA", "ABDBA", "AABAA", " AAA " }, - { " AAA ", "AAAAA", "AAAAA", "AAAAA", " AAA " } }; - //spotless:on - - private static final int HORIZONTAL_OFF_SET = 2; - private static final int VERTICAL_OFF_SET = 3; - private static final int DEPTH_OFF_SET = 0; - - private int tierGearBoxCasing = -1; - private int tierPipeCasing = -1; - private int tierFireBoxCasing = -1; - private int tierMachineCasing = -1; - - private int tCountCasing = 0; - - private int tierMachine = 1; - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - tCountCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - tCountCasing++; - return 2; - } - return 0; - } - - public static int getTierFireBoxCasing(Block block, int meta) { - if (block == sBlockCasings3 && 13 == meta) return 1; - if (block == sBlockCasings3 && 14 == meta) return 2; - return 0; - } - - public static int getTierGearBoxCasing(Block block, int meta) { - if (block == sBlockCasings2 && 2 == meta) return 1; - if (block == sBlockCasings2 && 3 == meta) return 2; - return 0; - } - - public static int getTierPipeCasing(Block block, int meta) { - if (block == sBlockCasings2 && 12 == meta) return 1; - if (block == sBlockCasings2 && 13 == meta) return 2; - return 0; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierFireBoxCasing == 2 || tierMachineCasing == 2) - return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - - STRUCTURE_DEFINITION = StructureDefinition.builder() - - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'B', - ofBlocksTiered( - GregtechMetaTileEntity_SteamCentrifuge::getTierGearBoxCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), - -1, - (t, m) -> t.tierGearBoxCasing = m, - t -> t.tierGearBoxCasing)) - .addElement( - 'C', - ofBlocksTiered( - GregtechMetaTileEntity_SteamCentrifuge::getTierPipeCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), - -1, - (t, m) -> t.tierPipeCasing = m, - t -> t.tierPipeCasing)) - .addElement( - 'D', - ofBlocksTiered( - GregtechMetaTileEntity_SteamCentrifuge::getTierFireBoxCasing, - ImmutableList.of(Pair.of(sBlockCasings3, 13), Pair.of(sBlockCasings3, 14)), - -1, - (t, m) -> t.tierFireBoxCasing = m, - t -> t.tierFireBoxCasing)) - .addElement( - 'A', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamCentrifuge.class).casingIndex(10) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamCentrifuge.class) - .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam, OutputHatch) - .casingIndex(10) - .dot(1) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - return this.survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - tierGearBoxCasing = -1; - tierPipeCasing = -1; - tierFireBoxCasing = -1; - tierMachineCasing = -1; - tCountCasing = 0; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierFireBoxCasing < 0 && tierMachineCasing < 0) return false; - if (tierGearBoxCasing == 1 && tierPipeCasing == 1 - && tierFireBoxCasing == 1 - && tierMachineCasing == 1 - && tCountCasing > 60 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierGearBoxCasing == 2 && tierPipeCasing == 2 - && tierFireBoxCasing == 2 - && tierMachineCasing == 2 - && tCountCasing > 60 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - return false; - } - - private boolean checkHatches() { - return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && !mOutputHatches.isEmpty() - && mInputHatches.isEmpty(); - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.centrifugeRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Centrifuge") - .addInfo("33.3% faster than a single block steam machine would run.") - .addInfo( - "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(5, 5, 5, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "60-65x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "3x" + EnumChatFormatting.GRAY + " Bronze Firebox Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "4x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "60-65x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "3x" + EnumChatFormatting.GRAY + " Steel Firebox Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "4x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") - .addStructureInfo("") - .toolTipFinisher(AuthorEvgenWarGold); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.GT_MACHINES_STEAM_CENTRIFUGE_LOOP.resourceLocation; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java deleted file mode 100644 index f2debf5981..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamCompressor.java +++ /dev/null @@ -1,352 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.GregTech_API.sBlockCasings1; -import static gregtech.api.GregTech_API.sBlockCasings2; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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.ResourceLocation; -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.google.common.collect.ImmutableList; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -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.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamCompressor - extends GregtechMeta_SteamMultiBase implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamCompressor(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamCompressor(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { - return new GregtechMetaTileEntity_SteamCompressor(this.mName); - } - - @Override - public String getMachineType() { - return "Compressor"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - - // spotless:off - private final String[][] shape = new String[][] { - { "CCC", "CCC", "CCC", "CCC" }, - { "C~C", "C-C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC", "CCC" } }; - //spotless:on - - private static final int HORIZONTAL_OFF_SET = 1; - private static final int VERTICAL_OFF_SET = 1; - private static final int DEPTH_OFF_SET = 0; - - private int mCountCasing = 0; - - private int tierMachine = 1; - - private int tierMachineCasing = -1; - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - mCountCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - mCountCasing++; - return 2; - } - return 0; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierMachineCasing == 2) return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'C', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamCompressor.class).casingIndex(10) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamCompressor.class) - .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) - .casingIndex(10) - .dot(1) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - return survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCountCasing = 0; - tierMachineCasing = -1; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierMachineCasing < 0) return false; - if (tierMachineCasing == 1 && mCountCasing > 25 && checkHatches()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierMachineCasing == 2 && mCountCasing > 25 && checkHatches()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - - return false; - } - - private boolean checkHatches() { - return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && mOutputHatches.isEmpty() - && mInputHatches.isEmpty(); - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.compressorRecipes; - } - - // note that a basic steam machine has .setEUtDiscount(2F).setSpeedBoost(2F). So these are bonuses. - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Compressor") - .addInfo("33.3% faster than using a single block Steam Compressor.") - .addInfo("Uses only 66.6% of the steam/s compared to a single block Steam Compressor.") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(3, 3, 4, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "25-30x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "25-30x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo("") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP.resourceLocation; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamForgeHammer.java deleted file mode 100644 index c444743ca9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamForgeHammer.java +++ /dev/null @@ -1,409 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.GregTech_API.sBlockCasings1; -import static gregtech.api.GregTech_API.sBlockCasings2; -import static gregtech.api.enums.GT_Values.AuthorEvgenWarGold; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -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.google.common.collect.ImmutableList; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -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.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamForgeHammer - extends GregtechMeta_SteamMultiBase implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamForgeHammer(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamForgeHammer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SteamForgeHammer(this.mName); - } - - @Override - public String getMachineType() { - return "Forge Hammer"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - - // spotless:off - private final String[][] shape = new String[][] { - {" "," "," B "," "," "}, - {" "," A ","AABAA"," A "," "}, - {" "," ","A C A"," "," "}, - {" "," ","A C A"," "," "}, - {" "," ","A A"," "," "}, - {" "," A~A ","AA AA"," AAA "," "}, - {" AAA ","AAAAA","AAAAA","AAAAA"," AAA "} }; - //spotless:on - - private static final int HORIZONTAL_OFF_SET = 2; - private static final int VERTICAL_OFF_SET = 5; - private static final int DEPTH_OFF_SET = 1; - - private int tierPipeCasing = -1; - private int tierMachineCasing = -1; - - private int tCountCasing = 0; - - private int tierMachine = 1; - - private int tierSimpleBlock = -1; - - public static int getTierSimpleBlock(Block block, int meta) { - if (block == Blocks.iron_block && meta == 0) return 1; - if (block == GregTech_API.sBlockMetal6 && meta == 13) return 2; - return 0; - } - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - tCountCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - tCountCasing++; - return 2; - } - return 0; - } - - public static int getTierPipeCasing(Block block, int meta) { - if (block == sBlockCasings2 && 12 == meta) return 1; - if (block == sBlockCasings2 && 13 == meta) return 2; - return 0; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierPipeCasing == 2 || tierMachineCasing == 2 || tierSimpleBlock == 2) - return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FORGE_HAMMER); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FORGE_HAMMER_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - - STRUCTURE_DEFINITION = StructureDefinition.builder() - - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'B', - ofBlocksTiered( - GregtechMetaTileEntity_SteamForgeHammer::getTierPipeCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), - -1, - (t, m) -> t.tierPipeCasing = m, - t -> t.tierPipeCasing)) - .addElement( - 'C', - ofBlocksTiered( - GregtechMetaTileEntity_SteamForgeHammer::getTierSimpleBlock, - ImmutableList.of(Pair.of(Blocks.iron_block, 0), Pair.of(GregTech_API.sBlockMetal6, 13)), - -1, - (t, m) -> t.tierSimpleBlock = m, - t -> t.tierSimpleBlock)) - .addElement( - 'A', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamForgeHammer.class).casingIndex(10) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamForgeHammer.class) - .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) - .casingIndex(10) - .dot(1) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - return this.survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - tierPipeCasing = -1; - tierMachineCasing = -1; - tierSimpleBlock = -1; - tCountCasing = 0; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierPipeCasing < 0 && tierMachineCasing < 0 && tierSimpleBlock < 0) return false; - if (tierPipeCasing == 1 && tierMachineCasing == 1 - && tierSimpleBlock == 1 - && tCountCasing > 35 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierPipeCasing == 2 && tierMachineCasing == 2 - && tierSimpleBlock == 2 - && tCountCasing > 35 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - return false; - } - - private boolean checkHatches() { - return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && mOutputHatches.isEmpty() - && mInputHatches.isEmpty(); - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.hammerRecipes; - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.RANDOM_ANVIL_USE.resourceLocation; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Forge Hammer") - .addInfo("33.3% faster than a single block steam machine would run.") - .addInfo( - "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(6, 5, 5, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "35-39x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Iron Block") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "35-39x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") - .addStructureInfo( - EnumChatFormatting.GOLD + "2x" - + EnumChatFormatting.GRAY - + " Steel Block" - + EnumChatFormatting.RED - + " from GregTech") - .addStructureInfo("") - .toolTipFinisher(AuthorEvgenWarGold); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java deleted file mode 100644 index 3a055d7403..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java +++ /dev/null @@ -1,354 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.GregTech_API.sBlockCasings1; -import static gregtech.api.GregTech_API.sBlockCasings2; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -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.ResourceLocation; -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.google.common.collect.ImmutableList; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -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.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamMacerator - extends GregtechMeta_SteamMultiBase implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamMacerator(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamMacerator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { - return new GregtechMetaTileEntity_SteamMacerator(this.mName); - } - - @Override - public String getMachineType() { - return "Macerator"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private final String[][] shape = new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC" } }; - // spotless:on - - private static final int HORIZONTAL_OFF_SET = 1; - private static final int VERTICAL_OFF_SET = 1; - private static final int DEPTH_OFF_SET = 0; - - private int mCounCasing = 0; - - private int tierMachine = 0; - - private int tierMachineCasing = -1; - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - mCounCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - mCounCasing++; - return 2; - } - return 0; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierMachineCasing == 2) return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'C', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamMacerator.class).casingIndex(10) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamMacerator.class) - .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) - .casingIndex(10) - .dot(1) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - return survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - tierMachineCasing = -1; - mCounCasing = 0; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierMachineCasing < 0) return false; - if (tierMachineCasing == 1 && mCounCasing > 14 && checkHatches()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierMachineCasing == 2 && mCounCasing > 14 && checkHatches()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - - return false; - } - - private boolean checkHatches() { - return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && mOutputHatches.isEmpty() - && mInputHatches.isEmpty(); - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.maceratorRecipes; - } - - @Override - public int getItemOutputLimit() { - return 1; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - // note that a basic steam machine has .setEUtDiscount(2F).setSpeedBoost(2F). So these here are bonuses. - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Macerator") - .addInfo("33.3% faster than using a single block Steam Macerator.") - .addInfo("Uses only 66.6% of the steam/s required compared to a single block Steam Macerator on Tier 1.") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(3, 3, 3, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "14-22x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "14-22x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo("") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.IC2_MACHINES_MACERATOR_OP.resourceLocation; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMixer.java deleted file mode 100644 index ae91b28152..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMixer.java +++ /dev/null @@ -1,458 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.GregTech_API.sBlockCasings1; -import static gregtech.api.GregTech_API.sBlockCasings2; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.enums.GT_Values.AuthorEvgenWarGold; -import static gregtech.api.enums.Mods.EnderIO; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -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.google.common.collect.ImmutableList; -import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; -import com.gtnewhorizon.structurelib.structure.ITierConverter; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -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.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamMixer extends GregtechMeta_SteamMultiBase - implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamMixer(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamMixer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SteamMixer(this.mName); - } - - @Override - public String getMachineType() { - return "Mixer"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - // spotless:off - private final String[][] shape = new String[][]{ - {" "," A "," A "," AAAAA "," A "," A "," "}, - {" A "," A "," ","AA B AA"," "," A "," A "}, - {" A "," "," ","A C A"," "," "," A "}, - {" AAAAA ","A A","A A","A C A","A A","A A"," AAAAA "}, - {" AA~AA ","AD DA","A D D A","A B A","A D D A","AD DA"," AAAAA "}, - {" AAAAA ","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA"," AAAAA "}}; - //spotless:on - - private static final int HORIZONTAL_OFF_SET = 3; - private static final int VERTICAL_OFF_SET = 4; - private static final int DEPTH_OFF_SET = 0; - - private int tierGearBoxCasing = -1; - private int tierPipeCasing = -1; - private int tierMachineCasing = -1; - - private int tCountCasing = 0; - - private int tierMachine = 1; - - private int tierSimpleBlock = 0; - - Map simpleBlockTiers = new HashMap<>(); - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - tCountCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - tCountCasing++; - return 2; - } - return 0; - } - - public static int getTierGearBoxCasing(Block block, int meta) { - if (block == sBlockCasings2 && 2 == meta) return 1; - if (block == sBlockCasings2 && 3 == meta) return 2; - return 0; - } - - public static int getTierPipeCasing(Block block, int meta) { - if (block == sBlockCasings2 && 12 == meta) return 1; - if (block == sBlockCasings2 && 13 == meta) return 2; - return 0; - } - - private static List> getAllSimpleBlockTiers(Map simpleBlockTiers) { - return simpleBlockTiers.entrySet() - .stream() - .map(e -> Pair.of(e.getKey(), e.getValue())) - .collect(Collectors.toList()); - } - - private static ITierConverter simpleBlockTierConverter(Map simpleBlockTiers) { - return (block, meta) -> block == null ? 0 : simpleBlockTiers.getOrDefault(block, 1); - } - - private void setSimpleBlockTier(int tier) { - tierSimpleBlock = tier; - } - - private int getSimpleBlockTier() { - return tierSimpleBlock; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierMachineCasing == 2 || tierSimpleBlock == 2) - return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - simpleBlockTiers.put(Blocks.iron_block, 1); - - if (EnderIO.isModLoaded()) { - simpleBlockTiers.put(GameRegistry.findBlock(EnderIO.ID, "blockIngotStorage"), 6); - } else simpleBlockTiers.put(Blocks.iron_block, 2); - - STRUCTURE_DEFINITION = StructureDefinition.builder() - - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'B', - ofBlocksTiered( - GregtechMetaTileEntity_SteamMixer::getTierGearBoxCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), - -1, - (t, m) -> t.tierGearBoxCasing = m, - t -> t.tierGearBoxCasing)) - .addElement( - 'C', - ofBlocksTiered( - GregtechMetaTileEntity_SteamMixer::getTierPipeCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), - -1, - (t, m) -> t.tierPipeCasing = m, - t -> t.tierPipeCasing)) - .addElement( - 'D', - ofBlocksTiered( - simpleBlockTierConverter(simpleBlockTiers), - getAllSimpleBlockTiers(simpleBlockTiers), - -1, - GregtechMetaTileEntity_SteamMixer::setSimpleBlockTier, - GregtechMetaTileEntity_SteamMixer::getSimpleBlockTier)) - .addElement( - 'A', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamMixer.class).casingIndex(10) - .dot(1) - .allowOnly(ForgeDirection.NORTH) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamMixer.class) - .atLeast( - SteamHatchElement.InputBus_Steam, - SteamHatchElement.OutputBus_Steam, - OutputHatch, - InputHatch) - .casingIndex(10) - .dot(1) - .allowOnly(ForgeDirection.NORTH) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - return this.survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - tierGearBoxCasing = -1; - tierPipeCasing = -1; - tierSimpleBlock = -1; - tierMachineCasing = -1; - tCountCasing = 0; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierMachineCasing < 0) return false; - if (tierGearBoxCasing == 1 && tierPipeCasing == 1 - && tierSimpleBlock == 1 - && tierMachineCasing == 1 - && tCountCasing > 90 - && !mSteamInputFluids.isEmpty() - && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && !mInputHatches.isEmpty() - && !mOutputHatches.isEmpty()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierGearBoxCasing == 2 && tierPipeCasing == 2 - && tierSimpleBlock == 2 - && tierMachineCasing == 2 - && tCountCasing > 90 - && !mSteamInputFluids.isEmpty() - && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && !mInputHatches.isEmpty() - && !mOutputHatches.isEmpty()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - return false; - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.mixerNonCellRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Mixer") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(7, 6, 7, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "90-100x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Block of Iron") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "90-100x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Block of Iron") - .addStructureInfo("") - .toolTipFinisher(AuthorEvgenWarGold); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.GT_MACHINES_STEAM_CENTRIFUGE_LOOP.resourceLocation; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWasher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWasher.java deleted file mode 100644 index a245f696f9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWasher.java +++ /dev/null @@ -1,552 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.GregTech_API.*; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_Values.AuthorEvgenWarGold; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -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.google.common.collect.ImmutableList; -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; -import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; -import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_Recipe; -import gregtech.common.blocks.GT_Block_Casings1; -import gregtech.common.blocks.GT_Block_Casings2; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamWasher extends GregtechMeta_SteamMultiBase - implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamWasher(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamWasher(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SteamWasher(this.mName); - } - - @Override - public String getMachineType() { - return "Washer"; - } - - private static final String STRUCTUR_PIECE_MAIN = "main"; - - private IStructureDefinition STRUCTURE_DEFINITION = null; - - private final String[][] shape = new String[][] { - { " ", " ", " CCCCCC ", " ", " " }, - { " ", " ", " C C ", " ", " " }, - { " AAA ", " A A", " C A C A", " A A", " AAA " }, - { " ADDDA", "AAA D D", "AAA D C D", "AAA D D", " ADDDA" }, - { " ADDDA", "A~A DEEED", "AAA DECED", "AAA DEEED", " ADDDA" }, - { " AAAAA", "AAA ABBBA", "AAA ABABA", "AAA ABBBA", " AAAAA" } }; - - private static final int HORIZONTAL_OFF_SET = 1; - private static final int VERTICAL_OFF_SET = 4; - private static final int DEPTH_OFF_SET = 1; - - private static final int MACHINEMODE_OREWASH = 0; - private static final int MACHINEMODE_SIMPLEWASH = 1; - - private boolean isBroken = true; - - private int tierGearBoxCasing = -1; - private int tierPipeCasing = -1; - private int tierMachineCasing = -1; - private int tierMachine = 1; - - private int tCountCasing = 0; - - public int getTierMachineCasing(Block block, int meta) { - if (block == sBlockCasings1 && 10 == meta) { - tCountCasing++; - return 1; - } - if (block == sBlockCasings2 && 0 == meta) { - tCountCasing++; - return 2; - } - return 0; - } - - public static int getTierGearBoxCasing(Block block, int meta) { - if (block == sBlockCasings2 && 2 == meta) return 1; - if (block == sBlockCasings2 && 3 == meta) return 2; - return 0; - } - - public static int getTierPipeCasing(Block block, int meta) { - if (block == sBlockCasings2 && 12 == meta) return 1; - if (block == sBlockCasings2 && 13 == meta) return 2; - return 0; - } - - protected void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); - } - - private int getCasingTextureID() { - if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierMachineCasing == 2) - return ((GT_Block_Casings2) GregTech_API.sBlockCasings2).getTextureIndex(0); - return ((GT_Block_Casings1) GregTech_API.sBlockCasings1).getTextureIndex(10); - } - - @Override - public void onValueUpdate(byte aValue) { - tierMachineCasing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) tierMachineCasing; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_WASHER); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_WASHER_ACTIVE); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - - STRUCTURE_DEFINITION = StructureDefinition.builder() - - .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) - .addElement( - 'B', - ofBlocksTiered( - GregtechMetaTileEntity_SteamWasher::getTierGearBoxCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), - -1, - (t, m) -> t.tierGearBoxCasing = m, - t -> t.tierGearBoxCasing)) - .addElement( - 'C', - ofBlocksTiered( - GregtechMetaTileEntity_SteamWasher::getTierPipeCasing, - ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), - -1, - (t, m) -> t.tierPipeCasing = m, - t -> t.tierPipeCasing)) - .addElement('D', ofBlock(Blocks.glass, 0)) - .addElement( - 'E', - ofChain( - isAir(), - ofBlockAnyMeta(Blocks.water), - ofBlockAnyMeta(BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)))) - .addElement( - 'A', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamWasher.class).casingIndex(10) - .dot(1) - .allowOnly(ForgeDirection.NORTH) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamWasher.class) - .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam, InputHatch) - .casingIndex(10) - .dot(1) - .allowOnly(ForgeDirection.NORTH) - .buildAndChain(), - ofBlocksTiered( - this::getTierMachineCasing, - ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), - -1, - (t, m) -> t.tierMachineCasing = m, - t -> t.tierMachineCasing))) - .build(); - - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - return this.survivialBuildPiece( - STRUCTUR_PIECE_MAIN, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - tierGearBoxCasing = -1; - tierPipeCasing = -1; - tierMachineCasing = -1; - tCountCasing = 0; - if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierMachineCasing < 0) return false; - if (tierGearBoxCasing == 1 && tierPipeCasing == 1 - && tierMachineCasing == 1 - && tCountCasing > 55 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 1; - return true; - } - if (tierGearBoxCasing == 2 && tierPipeCasing == 2 - && tierMachineCasing == 2 - && tCountCasing > 55 - && checkHatches()) { - updateHatchTexture(); - tierMachine = 2; - return true; - } - return false; - } - - private boolean checkHatches() { - return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() - && !mSteamOutputs.isEmpty() - && mOutputHatches.isEmpty() - && !mInputHatches.isEmpty(); - } - - @Override - public int getMaxParallelRecipes() { - return tierMachine == 1 ? 8 : 16; - } - - @Override - public RecipeMap getRecipeMap() { - if (machineMode == MACHINEMODE_SIMPLEWASH) { - return GTPPRecipeMaps.simpleWasherRecipes; - } - return RecipeMaps.oreWasherRecipes; - } - - @NotNull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(GTPPRecipeMaps.simpleWasherRecipes, RecipeMaps.oreWasherRecipes); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - if (isBroken) { - checkForWater(); - isBroken = false; - } else if (availableVoltage < recipe.mEUt) { - return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); - } else return CheckRecipeResultRegistry.SUCCESSFUL; - return SimpleCheckRecipeResult.ofFailure("no_water"); - } - - @Override - @Nonnull - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator.ofNoOverclock(recipe) - .setEUtDiscount(1.33F) - .setSpeedBoost(1.5F); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getTierRecipes() { - return tierMachine == 1 ? 1 : 2; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Steam Washer") - .addInfo("33.3% faster than a single block steam machine would run.") - .addInfo( - "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") - .addInfo("Bronze tier runs recipes up to LV tier") - .addInfo("Steel tier runs recipes up to MV tier") - .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") - .addSeparator() - .beginStructureBlock(5, 5, 5, false) - .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "55-59x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") - .addStructureInfo(EnumChatFormatting.GOLD + "24x" + EnumChatFormatting.GRAY + " Any Glass") - .addStructureInfo(EnumChatFormatting.GOLD + "12x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo( - EnumChatFormatting.GOLD + "55-59x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "24x" + EnumChatFormatting.GRAY + " Any Glass") - .addStructureInfo(EnumChatFormatting.GOLD + "12x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") - .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") - .addStructureInfo("") - .toolTipFinisher(AuthorEvgenWarGold); - return tt; - } - - @Override - public String[] getInfoData() { - ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); - info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); - info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); - return info.toArray(new String[0]); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GTPP.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tag.getInteger("tierMachine") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("parallel") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } - - @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); - tag.setInteger("tierMachine", tierMachine); - tag.setInteger("parallel", getMaxParallelRecipes()); - tag.setInteger("mode", machineMode); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("tierMachine", tierMachine); - aNBT.setInteger("mMode", machineMode); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - tierMachine = aNBT.getInteger("tierMachine"); - machineMode = aNBT.getInteger("mMode"); - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - // don't rotate a washer, water will flow out. - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.GT_MACHINES_STEAM_WASHER_LOOP.resourceLocation; - } - - @Override - public boolean supportsMachineModeSwitch() { - return true; - } - - @Override - public int nextMachineMode() { - if (machineMode == MACHINEMODE_OREWASH) return MACHINEMODE_SIMPLEWASH; - else return MACHINEMODE_OREWASH; - } - - @Override - public void setMachineModeIcons() { - machineModeIcons.clear(); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_WASHPLANT); - machineModeIcons.add(GT_UITextures.OVERLAY_BUTTON_MACHINEMODE_SIMPLEWASHER); - } - - @Override - public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + machineMode); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - if (mUpdate < -250) mUpdate = 50; - if ((aTick % 1200) == 0) { - isBroken = true; - } - } - } - - private void checkForWater() { - ExtendedFacing facing = getExtendedFacing(); - final ForgeDirection frontFacing = facing.getDirection(); - final Flip curFlip = facing.getFlip(); - IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); - - double xOffset = getExtendedFacing().getRelativeBackInWorld().offsetX; - double zOffset = getExtendedFacing().getRelativeBackInWorld().offsetZ; - double yOffset = getExtendedFacing().getRelativeBackInWorld().offsetY; - - switch (frontFacing) { - case WEST -> { - xOffset -= 1; - zOffset += curFlip.isHorizontallyFlipped() ? -6 : 4; - } - case EAST -> { - xOffset -= 1; - zOffset += curFlip.isHorizontallyFlipped() ? 4 : -6; - } - case NORTH -> { - zOffset -= 1; - xOffset += curFlip.isHorizontallyFlipped() ? 4 : -6; - } - case SOUTH -> { - zOffset -= 1; - xOffset += curFlip.isHorizontallyFlipped() ? -6 : 4; - } - } - - int x = gregTechTileEntity.getXCoord(); - int y = gregTechTileEntity.getYCoord(); - int z = gregTechTileEntity.getZCoord(); - - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - Block tBlock = this.getBaseMetaTileEntity() - .getWorld() - .getBlock((int) (i + xOffset + x), (int) (y + yOffset), (int) (j + zOffset + z)); - if (tBlock == Blocks.air) { - if (tryConsumeWater()) { - this.getBaseMetaTileEntity() - .getWorld() - .setBlock( - (int) (i + xOffset + x), - (int) (y + yOffset), - (int) (j + zOffset + z), - Blocks.water); - } - } - } - } - } - - private boolean tryConsumeWater() { - if (getStoredFluids() != null) { - for (FluidStack waterCapacity : this.getStoredFluids()) { - if (waterCapacity.isFluidEqual(FluidUtils.getWater(1000))) { - if (waterCapacity.amount >= 1000) { - waterCapacity.amount -= 1000; - return true; - } - } - } - } - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWaterPump.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWaterPump.java deleted file mode 100644 index 9d727b21ba..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamWaterPump.java +++ /dev/null @@ -1,374 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.enums.GT_Values.AuthorEvgenWarGold; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofFrame; - -import java.util.List; - -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.ResourceLocation; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -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.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -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.objects.GT_RenderedTexture; -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_Utility; -import gregtech.api.util.VoidProtectionHelper; -import gregtech.common.blocks.GT_Block_Casings9; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_SteamWaterPump - extends GregtechMeta_SteamMultiBase implements ISurvivalConstructable { - - public GregtechMetaTileEntity_SteamWaterPump(String aName) { - super(aName); - } - - public GregtechMetaTileEntity_SteamWaterPump(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SteamWaterPump(this.mName); - } - - @Override - public String getMachineType() { - return "Water Pump"; - } - - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final int HORIZONTAL_OFF_SET = 1; - private static final int VERTICAL_OFF_SET = 2; - private static final int DEPTH_OFF_SET = 0; - private static final String tier1 = "tier1"; - private static final String tier2 = "tier2"; - - // Base amount of water produced per second, before applying humidity and tier modifiers. - private static final int BASE_WATER_PER_SECOND = 1_500; - private static final int PROGRESSION_TIME_TICKS = 20; - - private static final int BASE_STEAM_PER_SECOND = 1_500; - - private int mSetTier = 1; - - private float currentHumidity; - - private static final Fluid water = FluidRegistry.getFluid("water"); - - private FluidStack[] getWater() { - return new FluidStack[] { new FluidStack(water, calculateFinalWaterOutput()) }; - } - - private int mCountCasing; - - private float getHumidity() { - return this.getBaseMetaTileEntity() - .getWorld() - .getBiomeGenForCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord()).rainfall; - } - - private int calculateFinalWaterOutput() { - return (int) (currentHumidity * BASE_WATER_PER_SECOND * mSetTier); - } - - // spotless:off - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - - STRUCTURE_DEFINITION = StructureDefinition.builder() - - .addShape( - tier1, - transpose( - new String[][] { - { " A ", " A ", "AAA", " A " }, - { " A ", " ", "A A", " A " }, - { "C~C", "CCC", "CCC", "CCC" } })) - .addShape( - tier2, - transpose( - new String[][] { - { " D ", " D ", "DDD", " D " }, - { " D ", " ", "D D", " D " }, - { "C~C", "CCC", "CCC", "CCC" } })) - .addElement('A', ofFrame(Materials.Bronze)) - .addElement('D', ofFrame(Materials.Steel)) - .addElement( - 'C', - ofChain( - buildSteamInput(GregtechMetaTileEntity_SteamWaterPump.class) - .casingIndex(((GT_Block_Casings9) GregTech_API.sBlockCasings9).getTextureIndex(2)) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_SteamWaterPump.class) - .atLeast(OutputHatch) - .casingIndex(((GT_Block_Casings9) GregTech_API.sBlockCasings9).getTextureIndex(2)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCountCasing, ofBlock(GregTech_API.sBlockCasings9, 2))) - ) - ) - .build(); - - } - return STRUCTURE_DEFINITION; - } - // spotless:on - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - if (stackSize.stackSize == 1) { - this.buildPiece(tier1, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } else { - this.buildPiece(tier2, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); - } - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (this.mMachine) return -1; - int built = 0; - if (stackSize.stackSize == 1) { - mSetTier = 1; - built += this.survivialBuildPiece( - tier1, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } else { - mSetTier = 2; - built += this.survivialBuildPiece( - tier2, - stackSize, - HORIZONTAL_OFF_SET, - VERTICAL_OFF_SET, - DEPTH_OFF_SET, - elementBudget, - env, - false, - true); - } - return built; - } - - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCountCasing = 0; - mSetTier = 1; - if (!checkPiece(tier1, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) { - if (!checkPiece(tier2, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; - mSetTier = 2; - } - - if (this.mOutputHatches.size() != 1 || this.mSteamInputFluids.size() != 1) return false; - - currentHumidity = getHumidity(); - return mCountCasing >= 9; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { - Textures.BlockIcons - .getCasingTextureForId(GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings9, 2)), - aActive ? getFrontOverlayActive() : getFrontOverlay() }; - } - return new ITexture[] { Textures.BlockIcons - .getCasingTextureForId(GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings9, 2)) }; - } - - @Override - protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_WATER_PUMP); - } - - @Override - protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_WATER_PUMP_ACTIVE); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Water Pump") - .addInfo("Pumps Water based on humidity") - .addInfo("Has 2 tiers: Bronze and Steel") - .addInfo("Steel tier extracts 2x Water") - .addInfo( - EnumChatFormatting.AQUA + "Generates: " - + EnumChatFormatting.WHITE - + " humidity * tier * " - + BASE_WATER_PER_SECOND - + " L/s" - + EnumChatFormatting.AQUA - + " of Water." - + EnumChatFormatting.RESET) - .addInfo( - EnumChatFormatting.RED + "Consumes: " - + EnumChatFormatting.WHITE - + BASE_STEAM_PER_SECOND - + " L/s" - + EnumChatFormatting.RED - + " of Steam." - + EnumChatFormatting.RESET) - .addSeparator() - .beginStructureBlock(3, 3, 5, false) - .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) - .addStructureInfo( - EnumChatFormatting.WHITE + "Steam Input Hatch " - + EnumChatFormatting.GOLD - + "1" - + EnumChatFormatting.GRAY - + " Any casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) - .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Bronze Frame Box") - .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Wooden Casing") - .addStructureInfo("") - .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) - .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Steel Frame Box") - .addStructureInfo(EnumChatFormatting.GOLD + "10 " + EnumChatFormatting.GRAY + " Wooden Casing") - .addStructureInfo("") - .toolTipFinisher(AuthorEvgenWarGold); - return tt; - } - - @Override - @NotNull - public CheckRecipeResult checkProcessing() { - - VoidProtectionHelper voidProtection = new VoidProtectionHelper().setMachine(this) - .setFluidOutputs(getWater()) - .build(); - - if (voidProtection.isFluidFull()) { - mOutputFluids = null; - mMaxProgresstime = 0; - return CheckRecipeResultRegistry.FLUID_OUTPUT_FULL; - } else { - if (getTotalSteamStored() >= BASE_STEAM_PER_SECOND) { - mMaxProgresstime = PROGRESSION_TIME_TICKS; - tryConsumeSteam(BASE_STEAM_PER_SECOND); - mOutputFluids = getWater(); - updateSlots(); - return CheckRecipeResultRegistry.SUCCESSFUL; - } else return CheckRecipeResultRegistry.NO_RECIPE; - } - } - - @Override - public int getTierRecipes() { - return 0; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - if ((aTick % 1200) == 0) { - currentHumidity = getHumidity(); - } - } - } - - @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); - - currenttip.add( - StatCollector.translateToLocal("GT5U.machines.tier") + ": " - + EnumChatFormatting.BLUE - + tag.getInteger("mSetTier") - + EnumChatFormatting.RESET); - currenttip.add( - StatCollector.translateToLocal("GT5U.biomes.humidity") + " " - + EnumChatFormatting.BLUE - + tag.getFloat("humidity") - + " %" - + EnumChatFormatting.RESET); - } - - @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); - tag.setFloat("humidity", currentHumidity * 100); - tag.setInteger("mSetTier", mSetTier); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mSetTier", mSetTier); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mSetTier = aNBT.getInteger("mSetTier"); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.GT_MACHINES_WATER_PUMP_LOOP.resourceLocation; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCentrifuge.java new file mode 100644 index 0000000000..7d2628d958 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCentrifuge.java @@ -0,0 +1,418 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.GregTechAPI.*; +import static gregtech.api.enums.GTValues.AuthorEvgenWarGold; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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.ResourceLocation; +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.google.common.collect.ImmutableList; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamCentrifuge extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamCentrifuge(String aName) { + super(aName); + } + + public MTESteamCentrifuge(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Centrifuge"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + // spotless:off + private final String[][] shape = new String[][] { + { " AAA ", "AAAAA", "AAAAA", "AAAAA", " AAA " }, + { " ", " ABA ", " BDB ", " ABA ", " " }, + { " A ", " ACA ", "ACDCA", " ACA ", " A " }, + { " A~A ", "AABAA", "ABDBA", "AABAA", " AAA " }, + { " AAA ", "AAAAA", "AAAAA", "AAAAA", " AAA " } }; + //spotless:on + + private static final int HORIZONTAL_OFF_SET = 2; + private static final int VERTICAL_OFF_SET = 3; + private static final int DEPTH_OFF_SET = 0; + + private int tierGearBoxCasing = -1; + private int tierPipeCasing = -1; + private int tierFireBoxCasing = -1; + private int tierMachineCasing = -1; + + private int tCountCasing = 0; + + private int tierMachine = 1; + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + tCountCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + tCountCasing++; + return 2; + } + return 0; + } + + public static int getTierFireBoxCasing(Block block, int meta) { + if (block == sBlockCasings3 && 13 == meta) return 1; + if (block == sBlockCasings3 && 14 == meta) return 2; + return 0; + } + + public static int getTierGearBoxCasing(Block block, int meta) { + if (block == sBlockCasings2 && 2 == meta) return 1; + if (block == sBlockCasings2 && 3 == meta) return 2; + return 0; + } + + public static int getTierPipeCasing(Block block, int meta) { + if (block == sBlockCasings2 && 12 == meta) return 1; + if (block == sBlockCasings2 && 13 == meta) return 2; + return 0; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierFireBoxCasing == 2 || tierMachineCasing == 2) + return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + + STRUCTURE_DEFINITION = StructureDefinition.builder() + + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'B', + ofBlocksTiered( + MTESteamCentrifuge::getTierGearBoxCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), + -1, + (t, m) -> t.tierGearBoxCasing = m, + t -> t.tierGearBoxCasing)) + .addElement( + 'C', + ofBlocksTiered( + MTESteamCentrifuge::getTierPipeCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), + -1, + (t, m) -> t.tierPipeCasing = m, + t -> t.tierPipeCasing)) + .addElement( + 'D', + ofBlocksTiered( + MTESteamCentrifuge::getTierFireBoxCasing, + ImmutableList.of(Pair.of(sBlockCasings3, 13), Pair.of(sBlockCasings3, 14)), + -1, + (t, m) -> t.tierFireBoxCasing = m, + t -> t.tierFireBoxCasing)) + .addElement( + 'A', + ofChain( + buildSteamInput(MTESteamCentrifuge.class).casingIndex(10) + .dot(1) + .build(), + buildHatchAdder(MTESteamCentrifuge.class) + .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam, OutputHatch) + .casingIndex(10) + .dot(1) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + tierGearBoxCasing = -1; + tierPipeCasing = -1; + tierFireBoxCasing = -1; + tierMachineCasing = -1; + tCountCasing = 0; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierFireBoxCasing < 0 && tierMachineCasing < 0) return false; + if (tierGearBoxCasing == 1 && tierPipeCasing == 1 + && tierFireBoxCasing == 1 + && tierMachineCasing == 1 + && tCountCasing > 60 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierGearBoxCasing == 2 && tierPipeCasing == 2 + && tierFireBoxCasing == 2 + && tierMachineCasing == 2 + && tCountCasing > 60 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + return false; + } + + private boolean checkHatches() { + return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && !mOutputHatches.isEmpty() + && mInputHatches.isEmpty(); + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.centrifugeRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Centrifuge") + .addInfo("33.3% faster than a single block steam machine would run.") + .addInfo( + "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(5, 5, 5, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "60-65x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "3x" + EnumChatFormatting.GRAY + " Bronze Firebox Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "4x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "60-65x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "3x" + EnumChatFormatting.GRAY + " Steel Firebox Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "4x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") + .addStructureInfo("") + .toolTipFinisher(AuthorEvgenWarGold); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_STEAM_CENTRIFUGE_LOOP.resourceLocation; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java new file mode 100644 index 0000000000..9588a5d11a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java @@ -0,0 +1,351 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.sBlockCasings1; +import static gregtech.api.GregTechAPI.sBlockCasings2; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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.ResourceLocation; +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.google.common.collect.ImmutableList; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamCompressor extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamCompressor(String aName) { + super(aName); + } + + public MTESteamCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new MTESteamCompressor(this.mName); + } + + @Override + public String getMachineType() { + return "Compressor"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + + // spotless:off + private final String[][] shape = new String[][] { + { "CCC", "CCC", "CCC", "CCC" }, + { "C~C", "C-C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC", "CCC" } }; + //spotless:on + + private static final int HORIZONTAL_OFF_SET = 1; + private static final int VERTICAL_OFF_SET = 1; + private static final int DEPTH_OFF_SET = 0; + + private int mCountCasing = 0; + + private int tierMachine = 1; + + private int tierMachineCasing = -1; + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + mCountCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + mCountCasing++; + return 2; + } + return 0; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierMachineCasing == 2) return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_COMPRESSOR_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'C', + ofChain( + buildSteamInput(MTESteamCompressor.class).casingIndex(10) + .dot(1) + .build(), + buildHatchAdder(MTESteamCompressor.class) + .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) + .casingIndex(10) + .dot(1) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + return survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCountCasing = 0; + tierMachineCasing = -1; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierMachineCasing < 0) return false; + if (tierMachineCasing == 1 && mCountCasing > 25 && checkHatches()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierMachineCasing == 2 && mCountCasing > 25 && checkHatches()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + + return false; + } + + private boolean checkHatches() { + return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && mOutputHatches.isEmpty() + && mInputHatches.isEmpty(); + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.compressorRecipes; + } + + // note that a basic steam machine has .setEUtDiscount(2F).setSpeedBoost(2F). So these are bonuses. + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Compressor") + .addInfo("33.3% faster than using a single block Steam Compressor.") + .addInfo("Uses only 66.6% of the steam/s compared to a single block Steam Compressor.") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(3, 3, 4, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "25-30x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "25-30x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo("") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP.resourceLocation; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamForgeHammer.java new file mode 100644 index 0000000000..76e3ade135 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamForgeHammer.java @@ -0,0 +1,408 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.sBlockCasings1; +import static gregtech.api.GregTechAPI.sBlockCasings2; +import static gregtech.api.enums.GTValues.AuthorEvgenWarGold; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +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.google.common.collect.ImmutableList; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamForgeHammer extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamForgeHammer(String aName) { + super(aName); + } + + public MTESteamForgeHammer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamForgeHammer(this.mName); + } + + @Override + public String getMachineType() { + return "Forge Hammer"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + + // spotless:off + private final String[][] shape = new String[][] { + {" "," "," B "," "," "}, + {" "," A ","AABAA"," A "," "}, + {" "," ","A C A"," "," "}, + {" "," ","A C A"," "," "}, + {" "," ","A A"," "," "}, + {" "," A~A ","AA AA"," AAA "," "}, + {" AAA ","AAAAA","AAAAA","AAAAA"," AAA "} }; + //spotless:on + + private static final int HORIZONTAL_OFF_SET = 2; + private static final int VERTICAL_OFF_SET = 5; + private static final int DEPTH_OFF_SET = 1; + + private int tierPipeCasing = -1; + private int tierMachineCasing = -1; + + private int tCountCasing = 0; + + private int tierMachine = 1; + + private int tierSimpleBlock = -1; + + public static int getTierSimpleBlock(Block block, int meta) { + if (block == Blocks.iron_block && meta == 0) return 1; + if (block == GregTechAPI.sBlockMetal6 && meta == 13) return 2; + return 0; + } + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + tCountCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + tCountCasing++; + return 2; + } + return 0; + } + + public static int getTierPipeCasing(Block block, int meta) { + if (block == sBlockCasings2 && 12 == meta) return 1; + if (block == sBlockCasings2 && 13 == meta) return 2; + return 0; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierPipeCasing == 2 || tierMachineCasing == 2 || tierSimpleBlock == 2) + return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FORGE_HAMMER); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FORGE_HAMMER_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + + STRUCTURE_DEFINITION = StructureDefinition.builder() + + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'B', + ofBlocksTiered( + MTESteamForgeHammer::getTierPipeCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), + -1, + (t, m) -> t.tierPipeCasing = m, + t -> t.tierPipeCasing)) + .addElement( + 'C', + ofBlocksTiered( + MTESteamForgeHammer::getTierSimpleBlock, + ImmutableList.of(Pair.of(Blocks.iron_block, 0), Pair.of(GregTechAPI.sBlockMetal6, 13)), + -1, + (t, m) -> t.tierSimpleBlock = m, + t -> t.tierSimpleBlock)) + .addElement( + 'A', + ofChain( + buildSteamInput(MTESteamForgeHammer.class).casingIndex(10) + .dot(1) + .build(), + buildHatchAdder(MTESteamForgeHammer.class) + .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) + .casingIndex(10) + .dot(1) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + tierPipeCasing = -1; + tierMachineCasing = -1; + tierSimpleBlock = -1; + tCountCasing = 0; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierPipeCasing < 0 && tierMachineCasing < 0 && tierSimpleBlock < 0) return false; + if (tierPipeCasing == 1 && tierMachineCasing == 1 + && tierSimpleBlock == 1 + && tCountCasing > 35 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierPipeCasing == 2 && tierMachineCasing == 2 + && tierSimpleBlock == 2 + && tCountCasing > 35 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + return false; + } + + private boolean checkHatches() { + return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && mOutputHatches.isEmpty() + && mInputHatches.isEmpty(); + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.hammerRecipes; + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.RANDOM_ANVIL_USE.resourceLocation; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Forge Hammer") + .addInfo("33.3% faster than a single block steam machine would run.") + .addInfo( + "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(6, 5, 5, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "35-39x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Iron Block") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "35-39x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "2x" + + EnumChatFormatting.GRAY + + " Steel Block" + + EnumChatFormatting.RED + + " from GregTech") + .addStructureInfo("") + .toolTipFinisher(AuthorEvgenWarGold); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMacerator.java new file mode 100644 index 0000000000..43e6245557 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMacerator.java @@ -0,0 +1,353 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.sBlockCasings1; +import static gregtech.api.GregTechAPI.sBlockCasings2; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +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.ResourceLocation; +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.google.common.collect.ImmutableList; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamMacerator extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamMacerator(String aName) { + super(aName); + } + + public MTESteamMacerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new MTESteamMacerator(this.mName); + } + + @Override + public String getMachineType() { + return "Macerator"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private final String[][] shape = new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, + { "CCC", "CCC", "CCC" } }; + // spotless:on + + private static final int HORIZONTAL_OFF_SET = 1; + private static final int VERTICAL_OFF_SET = 1; + private static final int DEPTH_OFF_SET = 0; + + private int mCounCasing = 0; + + private int tierMachine = 0; + + private int tierMachineCasing = -1; + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + mCounCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + mCounCasing++; + return 2; + } + return 0; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierMachineCasing == 2) return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'C', + ofChain( + buildSteamInput(MTESteamMacerator.class).casingIndex(10) + .dot(1) + .build(), + buildHatchAdder(MTESteamMacerator.class) + .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam) + .casingIndex(10) + .dot(1) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + return survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + tierMachineCasing = -1; + mCounCasing = 0; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierMachineCasing < 0) return false; + if (tierMachineCasing == 1 && mCounCasing > 14 && checkHatches()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierMachineCasing == 2 && mCounCasing > 14 && checkHatches()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + + return false; + } + + private boolean checkHatches() { + return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && mOutputHatches.isEmpty() + && mInputHatches.isEmpty(); + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.maceratorRecipes; + } + + @Override + public int getItemOutputLimit() { + return 1; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + // note that a basic steam machine has .setEUtDiscount(2F).setSpeedBoost(2F). So these here are bonuses. + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Macerator") + .addInfo("33.3% faster than using a single block Steam Macerator.") + .addInfo("Uses only 66.6% of the steam/s required compared to a single block Steam Macerator on Tier 1.") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "14-22x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "14-22x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo("") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.IC2_MACHINES_MACERATOR_OP.resourceLocation; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMixer.java new file mode 100644 index 0000000000..1fc6e55042 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMixer.java @@ -0,0 +1,457 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.sBlockCasings1; +import static gregtech.api.GregTechAPI.sBlockCasings2; +import static gregtech.api.enums.GTValues.AuthorEvgenWarGold; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +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.google.common.collect.ImmutableList; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.ITierConverter; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamMixer extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamMixer(String aName) { + super(aName); + } + + public MTESteamMixer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamMixer(this.mName); + } + + @Override + public String getMachineType() { + return "Mixer"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + // spotless:off + private final String[][] shape = new String[][]{ + {" "," A "," A "," AAAAA "," A "," A "," "}, + {" A "," A "," ","AA B AA"," "," A "," A "}, + {" A "," "," ","A C A"," "," "," A "}, + {" AAAAA ","A A","A A","A C A","A A","A A"," AAAAA "}, + {" AA~AA ","AD DA","A D D A","A B A","A D D A","AD DA"," AAAAA "}, + {" AAAAA ","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA"," AAAAA "}}; + //spotless:on + + private static final int HORIZONTAL_OFF_SET = 3; + private static final int VERTICAL_OFF_SET = 4; + private static final int DEPTH_OFF_SET = 0; + + private int tierGearBoxCasing = -1; + private int tierPipeCasing = -1; + private int tierMachineCasing = -1; + + private int tCountCasing = 0; + + private int tierMachine = 1; + + private int tierSimpleBlock = 0; + + Map simpleBlockTiers = new HashMap<>(); + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + tCountCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + tCountCasing++; + return 2; + } + return 0; + } + + public static int getTierGearBoxCasing(Block block, int meta) { + if (block == sBlockCasings2 && 2 == meta) return 1; + if (block == sBlockCasings2 && 3 == meta) return 2; + return 0; + } + + public static int getTierPipeCasing(Block block, int meta) { + if (block == sBlockCasings2 && 12 == meta) return 1; + if (block == sBlockCasings2 && 13 == meta) return 2; + return 0; + } + + private static List> getAllSimpleBlockTiers(Map simpleBlockTiers) { + return simpleBlockTiers.entrySet() + .stream() + .map(e -> Pair.of(e.getKey(), e.getValue())) + .collect(Collectors.toList()); + } + + private static ITierConverter simpleBlockTierConverter(Map simpleBlockTiers) { + return (block, meta) -> block == null ? 0 : simpleBlockTiers.getOrDefault(block, 1); + } + + private void setSimpleBlockTier(int tier) { + tierSimpleBlock = tier; + } + + private int getSimpleBlockTier() { + return tierSimpleBlock; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierMachineCasing == 2 || tierSimpleBlock == 2) + return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_CENTRIFUGE_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + simpleBlockTiers.put(Blocks.iron_block, 1); + + if (EnderIO.isModLoaded()) { + simpleBlockTiers.put(GameRegistry.findBlock(EnderIO.ID, "blockIngotStorage"), 6); + } else simpleBlockTiers.put(Blocks.iron_block, 2); + + STRUCTURE_DEFINITION = StructureDefinition.builder() + + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'B', + ofBlocksTiered( + MTESteamMixer::getTierGearBoxCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), + -1, + (t, m) -> t.tierGearBoxCasing = m, + t -> t.tierGearBoxCasing)) + .addElement( + 'C', + ofBlocksTiered( + MTESteamMixer::getTierPipeCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), + -1, + (t, m) -> t.tierPipeCasing = m, + t -> t.tierPipeCasing)) + .addElement( + 'D', + ofBlocksTiered( + simpleBlockTierConverter(simpleBlockTiers), + getAllSimpleBlockTiers(simpleBlockTiers), + -1, + MTESteamMixer::setSimpleBlockTier, + MTESteamMixer::getSimpleBlockTier)) + .addElement( + 'A', + ofChain( + buildSteamInput(MTESteamMixer.class).casingIndex(10) + .dot(1) + .allowOnly(ForgeDirection.NORTH) + .build(), + buildHatchAdder(MTESteamMixer.class) + .atLeast( + SteamHatchElement.InputBus_Steam, + SteamHatchElement.OutputBus_Steam, + OutputHatch, + InputHatch) + .casingIndex(10) + .dot(1) + .allowOnly(ForgeDirection.NORTH) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + tierGearBoxCasing = -1; + tierPipeCasing = -1; + tierSimpleBlock = -1; + tierMachineCasing = -1; + tCountCasing = 0; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierMachineCasing < 0) return false; + if (tierGearBoxCasing == 1 && tierPipeCasing == 1 + && tierSimpleBlock == 1 + && tierMachineCasing == 1 + && tCountCasing > 90 + && !mSteamInputFluids.isEmpty() + && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && !mInputHatches.isEmpty() + && !mOutputHatches.isEmpty()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierGearBoxCasing == 2 && tierPipeCasing == 2 + && tierSimpleBlock == 2 + && tierMachineCasing == 2 + && tCountCasing > 90 + && !mSteamInputFluids.isEmpty() + && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && !mInputHatches.isEmpty() + && !mOutputHatches.isEmpty()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.mixerNonCellRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Mixer") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(7, 6, 7, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "90-100x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Block of Iron") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "90-100x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "2x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Block of Iron") + .addStructureInfo("") + .toolTipFinisher(AuthorEvgenWarGold); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_STEAM_CENTRIFUGE_LOOP.resourceLocation; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWasher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWasher.java new file mode 100644 index 0000000000..438a762da6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWasher.java @@ -0,0 +1,551 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.GregTechAPI.*; +import static gregtech.api.enums.GTValues.AuthorEvgenWarGold; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +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.google.common.collect.ImmutableList; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +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.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +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.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.common.blocks.BlockCasings1; +import gregtech.common.blocks.BlockCasings2; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamWasher extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamWasher(String aName) { + super(aName); + } + + public MTESteamWasher(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamWasher(this.mName); + } + + @Override + public String getMachineType() { + return "Washer"; + } + + private static final String STRUCTUR_PIECE_MAIN = "main"; + + private IStructureDefinition STRUCTURE_DEFINITION = null; + + private final String[][] shape = new String[][] { + { " ", " ", " CCCCCC ", " ", " " }, + { " ", " ", " C C ", " ", " " }, + { " AAA ", " A A", " C A C A", " A A", " AAA " }, + { " ADDDA", "AAA D D", "AAA D C D", "AAA D D", " ADDDA" }, + { " ADDDA", "A~A DEEED", "AAA DECED", "AAA DEEED", " ADDDA" }, + { " AAAAA", "AAA ABBBA", "AAA ABABA", "AAA ABBBA", " AAAAA" } }; + + private static final int HORIZONTAL_OFF_SET = 1; + private static final int VERTICAL_OFF_SET = 4; + private static final int DEPTH_OFF_SET = 1; + + private static final int MACHINEMODE_OREWASH = 0; + private static final int MACHINEMODE_SIMPLEWASH = 1; + + private boolean isBroken = true; + + private int tierGearBoxCasing = -1; + private int tierPipeCasing = -1; + private int tierMachineCasing = -1; + private int tierMachine = 1; + + private int tCountCasing = 0; + + public int getTierMachineCasing(Block block, int meta) { + if (block == sBlockCasings1 && 10 == meta) { + tCountCasing++; + return 1; + } + if (block == sBlockCasings2 && 0 == meta) { + tCountCasing++; + return 2; + } + return 0; + } + + public static int getTierGearBoxCasing(Block block, int meta) { + if (block == sBlockCasings2 && 2 == meta) return 1; + if (block == sBlockCasings2 && 3 == meta) return 2; + return 0; + } + + public static int getTierPipeCasing(Block block, int meta) { + if (block == sBlockCasings2 && 12 == meta) return 1; + if (block == sBlockCasings2 && 13 == meta) return 2; + return 0; + } + + protected void updateHatchTexture() { + for (MTEHatch h : mSteamInputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamOutputs) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mSteamInputFluids) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + } + + private int getCasingTextureID() { + if (tierGearBoxCasing == 2 || tierPipeCasing == 2 || tierMachineCasing == 2) + return ((BlockCasings2) GregTechAPI.sBlockCasings2).getTextureIndex(0); + return ((BlockCasings1) GregTechAPI.sBlockCasings1).getTextureIndex(10); + } + + @Override + public void onValueUpdate(byte aValue) { + tierMachineCasing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) tierMachineCasing; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_WASHER); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_WASHER_ACTIVE); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureID()) }; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + + STRUCTURE_DEFINITION = StructureDefinition.builder() + + .addShape(STRUCTUR_PIECE_MAIN, transpose(shape)) + .addElement( + 'B', + ofBlocksTiered( + MTESteamWasher::getTierGearBoxCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 2), Pair.of(sBlockCasings2, 3)), + -1, + (t, m) -> t.tierGearBoxCasing = m, + t -> t.tierGearBoxCasing)) + .addElement( + 'C', + ofBlocksTiered( + MTESteamWasher::getTierPipeCasing, + ImmutableList.of(Pair.of(sBlockCasings2, 12), Pair.of(sBlockCasings2, 13)), + -1, + (t, m) -> t.tierPipeCasing = m, + t -> t.tierPipeCasing)) + .addElement('D', ofBlock(Blocks.glass, 0)) + .addElement( + 'E', + ofChain( + isAir(), + ofBlockAnyMeta(Blocks.water), + ofBlockAnyMeta(BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)))) + .addElement( + 'A', + ofChain( + buildSteamInput(MTESteamWasher.class).casingIndex(10) + .dot(1) + .allowOnly(ForgeDirection.NORTH) + .build(), + buildHatchAdder(MTESteamWasher.class) + .atLeast(SteamHatchElement.InputBus_Steam, SteamHatchElement.OutputBus_Steam, InputHatch) + .casingIndex(10) + .dot(1) + .allowOnly(ForgeDirection.NORTH) + .buildAndChain(), + ofBlocksTiered( + this::getTierMachineCasing, + ImmutableList.of(Pair.of(sBlockCasings1, 10), Pair.of(sBlockCasings2, 0)), + -1, + (t, m) -> t.tierMachineCasing = m, + t -> t.tierMachineCasing))) + .build(); + + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTUR_PIECE_MAIN, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece( + STRUCTUR_PIECE_MAIN, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + tierGearBoxCasing = -1; + tierPipeCasing = -1; + tierMachineCasing = -1; + tCountCasing = 0; + if (!checkPiece(STRUCTUR_PIECE_MAIN, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + if (tierGearBoxCasing < 0 && tierPipeCasing < 0 && tierMachineCasing < 0) return false; + if (tierGearBoxCasing == 1 && tierPipeCasing == 1 + && tierMachineCasing == 1 + && tCountCasing > 55 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 1; + return true; + } + if (tierGearBoxCasing == 2 && tierPipeCasing == 2 + && tierMachineCasing == 2 + && tCountCasing > 55 + && checkHatches()) { + updateHatchTexture(); + tierMachine = 2; + return true; + } + return false; + } + + private boolean checkHatches() { + return !mSteamInputFluids.isEmpty() && !mSteamInputs.isEmpty() + && !mSteamOutputs.isEmpty() + && mOutputHatches.isEmpty() + && !mInputHatches.isEmpty(); + } + + @Override + public int getMaxParallelRecipes() { + return tierMachine == 1 ? 8 : 16; + } + + @Override + public RecipeMap getRecipeMap() { + if (machineMode == MACHINEMODE_SIMPLEWASH) { + return GTPPRecipeMaps.simpleWasherRecipes; + } + return RecipeMaps.oreWasherRecipes; + } + + @NotNull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(GTPPRecipeMaps.simpleWasherRecipes, RecipeMaps.oreWasherRecipes); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (isBroken) { + checkForWater(); + isBroken = false; + } else if (availableVoltage < recipe.mEUt) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } else return CheckRecipeResultRegistry.SUCCESSFUL; + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + + @Override + @Nonnull + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator.ofNoOverclock(recipe) + .setEUtDiscount(1.33F) + .setSpeedBoost(1.5F); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getTierRecipes() { + return tierMachine == 1 ? 1 : 2; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Washer") + .addInfo("33.3% faster than a single block steam machine would run.") + .addInfo( + "On Tier 1, it uses only 66.6% of the steam/s required compared to what a single block steam machine would use.") + .addInfo("Bronze tier runs recipes up to LV tier") + .addInfo("Steel tier runs recipes up to MV tier") + .addInfo("Processes 8x parallel Bronze tier and 16x parallel Steel tier") + .addSeparator() + .beginStructureBlock(5, 5, 5, false) + .addInputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addOutputBus(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "55-59x" + EnumChatFormatting.GRAY + " Bronze Plated Bricks") + .addStructureInfo(EnumChatFormatting.GOLD + "24x" + EnumChatFormatting.GRAY + " Any Glass") + .addStructureInfo(EnumChatFormatting.GOLD + "12x" + EnumChatFormatting.GRAY + " Bronze Pipe Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Bronze Gear Box Casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo( + EnumChatFormatting.GOLD + "55-59x" + EnumChatFormatting.GRAY + " Solid Steel Machine Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "24x" + EnumChatFormatting.GRAY + " Any Glass") + .addStructureInfo(EnumChatFormatting.GOLD + "12x" + EnumChatFormatting.GRAY + " Steel Pipe Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "8x" + EnumChatFormatting.GRAY + " Steel Gear Box Casing") + .addStructureInfo("") + .toolTipFinisher(AuthorEvgenWarGold); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Machine Tier: " + EnumChatFormatting.YELLOW + tierMachine); + info.add("Parallel: " + EnumChatFormatting.YELLOW + getMaxParallelRecipes()); + return info.toArray(new String[0]); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tag.getInteger("tierMachine") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("parallel") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } + + @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); + tag.setInteger("tierMachine", tierMachine); + tag.setInteger("parallel", getMaxParallelRecipes()); + tag.setInteger("mode", machineMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("tierMachine", tierMachine); + aNBT.setInteger("mMode", machineMode); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + tierMachine = aNBT.getInteger("tierMachine"); + machineMode = aNBT.getInteger("mMode"); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a washer, water will flow out. + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_STEAM_WASHER_LOOP.resourceLocation; + } + + @Override + public boolean supportsMachineModeSwitch() { + return true; + } + + @Override + public int nextMachineMode() { + if (machineMode == MACHINEMODE_OREWASH) return MACHINEMODE_SIMPLEWASH; + else return MACHINEMODE_OREWASH; + } + + @Override + public void setMachineModeIcons() { + machineModeIcons.clear(); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_WASHPLANT); + machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_SIMPLEWASHER); + } + + @Override + public String getMachineModeName() { + return StatCollector.translateToLocal("GT5U.GTPP_MULTI_WASH_PLANT.mode." + machineMode); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (mUpdate < -250) mUpdate = 50; + if ((aTick % 1200) == 0) { + isBroken = true; + } + } + } + + private void checkForWater() { + ExtendedFacing facing = getExtendedFacing(); + final ForgeDirection frontFacing = facing.getDirection(); + final Flip curFlip = facing.getFlip(); + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + double xOffset = getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = getExtendedFacing().getRelativeBackInWorld().offsetY; + + switch (frontFacing) { + case WEST -> { + xOffset -= 1; + zOffset += curFlip.isHorizontallyFlipped() ? -6 : 4; + } + case EAST -> { + xOffset -= 1; + zOffset += curFlip.isHorizontallyFlipped() ? 4 : -6; + } + case NORTH -> { + zOffset -= 1; + xOffset += curFlip.isHorizontallyFlipped() ? 4 : -6; + } + case SOUTH -> { + zOffset -= 1; + xOffset += curFlip.isHorizontallyFlipped() ? -6 : 4; + } + } + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + Block tBlock = this.getBaseMetaTileEntity() + .getWorld() + .getBlock((int) (i + xOffset + x), (int) (y + yOffset), (int) (j + zOffset + z)); + if (tBlock == Blocks.air) { + if (tryConsumeWater()) { + this.getBaseMetaTileEntity() + .getWorld() + .setBlock( + (int) (i + xOffset + x), + (int) (y + yOffset), + (int) (j + zOffset + z), + Blocks.water); + } + } + } + } + } + + private boolean tryConsumeWater() { + if (getStoredFluids() != null) { + for (FluidStack waterCapacity : this.getStoredFluids()) { + if (waterCapacity.isFluidEqual(FluidUtils.getWater(1000))) { + if (waterCapacity.amount >= 1000) { + waterCapacity.amount -= 1000; + return true; + } + } + } + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWaterPump.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWaterPump.java new file mode 100644 index 0000000000..8b11690673 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamWaterPump.java @@ -0,0 +1,373 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +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.GTValues.AuthorEvgenWarGold; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofFrame; + +import java.util.List; + +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.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +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.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +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.objects.GTRenderedTexture; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.VoidProtectionHelper; +import gregtech.common.blocks.BlockCasings9; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.MTESteamMultiBase; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTESteamWaterPump extends MTESteamMultiBase implements ISurvivalConstructable { + + public MTESteamWaterPump(String aName) { + super(aName); + } + + public MTESteamWaterPump(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamWaterPump(this.mName); + } + + @Override + public String getMachineType() { + return "Water Pump"; + } + + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final int HORIZONTAL_OFF_SET = 1; + private static final int VERTICAL_OFF_SET = 2; + private static final int DEPTH_OFF_SET = 0; + private static final String tier1 = "tier1"; + private static final String tier2 = "tier2"; + + // Base amount of water produced per second, before applying humidity and tier modifiers. + private static final int BASE_WATER_PER_SECOND = 1_500; + private static final int PROGRESSION_TIME_TICKS = 20; + + private static final int BASE_STEAM_PER_SECOND = 1_500; + + private int mSetTier = 1; + + private float currentHumidity; + + private static final Fluid water = FluidRegistry.getFluid("water"); + + private FluidStack[] getWater() { + return new FluidStack[] { new FluidStack(water, calculateFinalWaterOutput()) }; + } + + private int mCountCasing; + + private float getHumidity() { + return this.getBaseMetaTileEntity() + .getWorld() + .getBiomeGenForCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord()).rainfall; + } + + private int calculateFinalWaterOutput() { + return (int) (currentHumidity * BASE_WATER_PER_SECOND * mSetTier); + } + + // spotless:off + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + + STRUCTURE_DEFINITION = StructureDefinition.builder() + + .addShape( + tier1, + transpose( + new String[][] { + { " A ", " A ", "AAA", " A " }, + { " A ", " ", "A A", " A " }, + { "C~C", "CCC", "CCC", "CCC" } })) + .addShape( + tier2, + transpose( + new String[][] { + { " D ", " D ", "DDD", " D " }, + { " D ", " ", "D D", " D " }, + { "C~C", "CCC", "CCC", "CCC" } })) + .addElement('A', ofFrame(Materials.Bronze)) + .addElement('D', ofFrame(Materials.Steel)) + .addElement( + 'C', + ofChain( + buildSteamInput(MTESteamWaterPump.class) + .casingIndex(((BlockCasings9) GregTechAPI.sBlockCasings9).getTextureIndex(2)) + .dot(1) + .build(), + buildHatchAdder(MTESteamWaterPump.class) + .atLeast(OutputHatch) + .casingIndex(((BlockCasings9) GregTechAPI.sBlockCasings9).getTextureIndex(2)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCountCasing, ofBlock(GregTechAPI.sBlockCasings9, 2))) + ) + ) + .build(); + + } + return STRUCTURE_DEFINITION; + } + // spotless:on + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + if (stackSize.stackSize == 1) { + this.buildPiece(tier1, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } else { + this.buildPiece(tier2, stackSize, hintsOnly, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET); + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + int built = 0; + if (stackSize.stackSize == 1) { + mSetTier = 1; + built += this.survivialBuildPiece( + tier1, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } else { + mSetTier = 2; + built += this.survivialBuildPiece( + tier2, + stackSize, + HORIZONTAL_OFF_SET, + VERTICAL_OFF_SET, + DEPTH_OFF_SET, + elementBudget, + env, + false, + true); + } + return built; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCountCasing = 0; + mSetTier = 1; + if (!checkPiece(tier1, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) { + if (!checkPiece(tier2, HORIZONTAL_OFF_SET, VERTICAL_OFF_SET, DEPTH_OFF_SET)) return false; + mSetTier = 2; + } + + if (this.mOutputHatches.size() != 1 || this.mSteamInputFluids.size() != 1) return false; + + currentHumidity = getHumidity(); + return mCountCasing >= 9; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { + Textures.BlockIcons + .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings9, 2)), + aActive ? getFrontOverlayActive() : getFrontOverlay() }; + } + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings9, 2)) }; + } + + @Override + protected GTRenderedTexture getFrontOverlay() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_WATER_PUMP); + } + + @Override + protected GTRenderedTexture getFrontOverlayActive() { + return new GTRenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_WATER_PUMP_ACTIVE); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Water Pump") + .addInfo("Pumps Water based on humidity") + .addInfo("Has 2 tiers: Bronze and Steel") + .addInfo("Steel tier extracts 2x Water") + .addInfo( + EnumChatFormatting.AQUA + "Generates: " + + EnumChatFormatting.WHITE + + " humidity * tier * " + + BASE_WATER_PER_SECOND + + " L/s" + + EnumChatFormatting.AQUA + + " of Water." + + EnumChatFormatting.RESET) + .addInfo( + EnumChatFormatting.RED + "Consumes: " + + EnumChatFormatting.WHITE + + BASE_STEAM_PER_SECOND + + " L/s" + + EnumChatFormatting.RED + + " of Steam." + + EnumChatFormatting.RESET) + .addSeparator() + .beginStructureBlock(3, 3, 5, false) + .addInputHatch(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Any casing", 1) + .addStructureInfo( + EnumChatFormatting.WHITE + "Steam Input Hatch " + + EnumChatFormatting.GOLD + + "1" + + EnumChatFormatting.GRAY + + " Any casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 1) + .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Bronze Frame Box") + .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Wooden Casing") + .addStructureInfo("") + .addStructureInfo(EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 2) + .addStructureInfo(EnumChatFormatting.GOLD + "10" + EnumChatFormatting.GRAY + " Steel Frame Box") + .addStructureInfo(EnumChatFormatting.GOLD + "10 " + EnumChatFormatting.GRAY + " Wooden Casing") + .addStructureInfo("") + .toolTipFinisher(AuthorEvgenWarGold); + return tt; + } + + @Override + @NotNull + public CheckRecipeResult checkProcessing() { + + VoidProtectionHelper voidProtection = new VoidProtectionHelper().setMachine(this) + .setFluidOutputs(getWater()) + .build(); + + if (voidProtection.isFluidFull()) { + mOutputFluids = null; + mMaxProgresstime = 0; + return CheckRecipeResultRegistry.FLUID_OUTPUT_FULL; + } else { + if (getTotalSteamStored() >= BASE_STEAM_PER_SECOND) { + mMaxProgresstime = PROGRESSION_TIME_TICKS; + tryConsumeSteam(BASE_STEAM_PER_SECOND); + mOutputFluids = getWater(); + updateSlots(); + return CheckRecipeResultRegistry.SUCCESSFUL; + } else return CheckRecipeResultRegistry.NO_RECIPE; + } + } + + @Override + public int getTierRecipes() { + return 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick % 1200) == 0) { + currentHumidity = getHumidity(); + } + } + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + + currenttip.add( + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.BLUE + + tag.getInteger("mSetTier") + + EnumChatFormatting.RESET); + currenttip.add( + StatCollector.translateToLocal("GT5U.biomes.humidity") + " " + + EnumChatFormatting.BLUE + + tag.getFloat("humidity") + + " %" + + EnumChatFormatting.RESET); + } + + @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); + tag.setFloat("humidity", currentHumidity * 100); + tag.setInteger("mSetTier", mSetTier); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSetTier", mSetTier); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSetTier = aNBT.getInteger("mSetTier"); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_WATER_PUMP_LOOP.resourceLocation; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java deleted file mode 100644 index 6cae5e4bcd..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ /dev/null @@ -1,196 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - protected GT_Recipe lastRecipeToBuffer; - private int casing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GT4Entity_AutoCrafter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT4Entity_AutoCrafter(String mName) { - super(mName); - } - - @Override - public String getMachineType() { - return "Assembler"; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity tileEntity) { - return new GT4Entity_AutoCrafter(this.mName); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getMaxEfficiency(ItemStack itemStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Highly Advanced Assembling Machine") - .addInfo("200% faster than using single block machines of the same voltage") - .addInfo("Processes two items per voltage tier") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoRange("Bulk Production Frame", 10, 25, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 10); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GT4Entity_AutoCrafter.class) - .atLeast(InputBus, OutputBus, InputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack itemStack, boolean hintsOnly) { - buildPiece(mName, itemStack, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, itemStack, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity baseMetaTileEntity, ItemStack itemStack) { - casing = 0; - return checkPiece(mName, 1, 1, 0) && casing >= 10 && checkHatch(); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.assemblerRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 3F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - public int getMaxParallelRecipes() { - return 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); - } - - @Override - public String[] getExtraInfoData() { - final String running = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); - final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" - : "Needs Maintenance"); - String tSpecialText; - - if (lastRecipeToBuffer != null && lastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { - tSpecialText = "Currently processing: " + lastRecipeToBuffer.mOutputs[0].getDisplayName(); - } else { - tSpecialText = "Currently processing: Nothing"; - } - - return new String[] { "Large Scale Auto-Assembler v1.01c", running, maintenance, tSpecialText }; - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java deleted file mode 100644 index 694444f423..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java +++ /dev/null @@ -1,353 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.util.GT_StructureUtility.buildHatchAdder; - -import java.util.stream.Stream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_ParallelHelper; -import gregtech.api.util.GT_Recipe; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final int lavaFilterResilience = 30; // Damage lava filter with 1/n probability every operation. - private int dryHeatCounter = 0; // Counts up to dryHeatMaximum to check for explosion conditions. - private static final int dryHeatMaximum = 10; // 10 consecutive operations without water = BOOM - - private static final Item itemLavaFilter = ItemList.Component_LavaFilter.getItem(); - private static final Item itemObsidian = Item.getItemFromBlock(Blocks.obsidian); - private static final Fluid fluidWater = FluidRegistry.WATER; - private static final Fluid fluidDistilledWater = FluidUtils.getDistilledWater(1) - .getFluid(); - private static final Fluid fluidSteam = FluidUtils.getSteam(1) - .getFluid(); - private static final Fluid fluidSHSteam = FluidUtils.getSuperHeatedSteam(1) - .getFluid(); - - public GT4Entity_ThermalBoiler(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT4Entity_ThermalBoiler(String mName) { - super(mName); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_ThermalBoiler(this.mName); - } - - @Override - public String getMachineType() { - return "Boiler"; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return (aStack != null && aStack.getItem() == itemLavaFilter) ? 1 : 0; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.thermalBoilerRecipes; - } - - @Override - protected boolean filtersFluid() { - return false; - } - - @Override - public boolean supportsVoidProtection() { - return true; - } - - @Override - public boolean supportsBatchMode() { - return false; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - // Only test against the first fluid input in the recipe. - // We still want to run if we lack water (and subsequently explode). - @NotNull - @Override - protected Stream findRecipeMatches(@Nullable RecipeMap map) { - if (lastRecipe != null && depleteInput(lastRecipe.mFluidInputs[0], true)) { - return Stream.of(lastRecipe); - } - if (map == null) { - return Stream.empty(); - } - return map.getAllRecipes() - .stream() - .filter(recipe -> depleteInput(recipe.mFluidInputs[0], true)); - } - - @NotNull - @Override - protected GT_ParallelHelper createParallelHelper(@Nonnull GT_Recipe recipe) { - GT_Recipe adjustedRecipe = recipe.copy(); - - // Hack the recipe logic to not consume water, so that we can explode. - for (FluidStack inputFluid : adjustedRecipe.mFluidInputs) { - if (inputFluid != null - && (inputFluid.getFluid() == fluidWater || inputFluid.getFluid() == fluidDistilledWater)) { - inputFluid.amount = 0; - } - } - - // If we don't have a lava filter, remove non-obsidian outputs - // so that output space for them is not required if void protection is on. - if (!findLavaFilter()) { - for (ItemStack outputItem : adjustedRecipe.mOutputs) { - if (outputItem != null && outputItem.getItem() != itemObsidian) { - outputItem.stackSize = 0; - } - } - } - return super.createParallelHelper(adjustedRecipe); - } - }; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - // super.checkProcessing() instantly sets efficiency to maximum, override this. - int efficiency = mEfficiency; - CheckRecipeResult result = super.checkProcessing(); - if (result.wasSuccessful()) { - mEfficiency = efficiency; - mEfficiencyIncrease = mMaxProgresstime * getEfficiencyIncrease(); - - // Adjust steam output based on efficiency. - if (mOutputFluids != null) { - for (FluidStack outputFluid : mOutputFluids) { - if (outputFluid != null - && (outputFluid.getFluid() == fluidSteam || outputFluid.getFluid() == fluidSHSteam)) { - - // Purely for display reasons, we don't actually make any EU. - if (outputFluid.getFluid() == fluidSteam) { - lEUt = outputFluid.amount / mMaxProgresstime / 2; - } else { - lEUt = outputFluid.amount / mMaxProgresstime; - } - - // Adjust steam output based on efficiency. - // TODO: This is not reflected in the GUI while the player has it open?? - if (mEfficiency < getMaxEfficiency(null)) { - outputFluid.amount = Math - .max(1, (outputFluid.amount * mEfficiency) / getMaxEfficiency(null)); - } - - // Consume water to run recipe. - if (!useWater(outputFluid.amount)) { - outputFluid.amount = 0; - lEUt = 0; - } - } - } - } - - // Remove non-obsidian outputs if we can't damage lava filter. - if (mOutputItems != null && mOutputItems.length > 0) { - if (!damageLavaFilter()) { - for (ItemStack outputItem : mOutputItems) { - if (outputItem != null && outputItem.getItem() != itemObsidian) { - outputItem.stackSize = 0; - } - } - } - } - } - return result; - } - - private boolean findLavaFilter() { - if (getControllerSlot() == null) { - for (var bus : mInputBusses) { - for (ItemStack stack : bus.mInventory) { - if (stack != null && stack.getItem() == itemLavaFilter) { - setGUIItemStack(stack); - return true; - } - } - } - return false; - } else { - return getControllerSlot().getItem() == itemLavaFilter; - } - } - - private boolean damageLavaFilter() { - if (!findLavaFilter()) return false; - if (getBaseMetaTileEntity().getRandomNumber(lavaFilterResilience) > 0) return true; - - ItemStack filter = getControllerSlot(); - if (filter.attemptDamageItem(1, getBaseMetaTileEntity().getWorld().rand)) { - mInventory[1] = null; - } - return true; - } - - private boolean useWater(int steamAmount) { - // Round up to not dupe decimal amounts of water. - int waterAmount = Math.floorDiv(steamAmount + GT_Values.STEAM_PER_WATER - 1, GT_Values.STEAM_PER_WATER); - if (depleteInput(FluidUtils.getWater(waterAmount)) || depleteInput(FluidUtils.getDistilledWater(waterAmount))) { - dryHeatCounter = 0; - return true; - } else { - // Add some leniency with explosions. - if (dryHeatCounter < dryHeatMaximum) { - ++dryHeatCounter; - } else { - GT_Log.exp.println(this.mName + " was too hot and had no more Water!"); - explodeMultiblock(); // Generate crater - } - return false; - } - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - public int getEfficiencyIncrease() { - return 12; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Thermal Boiler Controller") - .addInfo("Converts Water & Heat into Steam") - .addInfo("Filters raw materials from lava") - .addInfo("Explodes if water is not supplied") - .addInfo("Consult user manual for more information") - .addPollutionAmount(getPollutionPerSecond(null)) - .beginStructureBlock(3, 3, 3, true) - .addController("Front Center") - .addCasingInfoMin("Thermal Containment Casings", 10, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAThermalBoilerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAThermalBoiler; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(1); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GT4Entity_ThermalBoiler.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Muffler) - .casingIndex(TAE.getIndexFromPage(0, 1)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 11)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java deleted file mode 100644 index 3b99849803..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java +++ /dev/null @@ -1,352 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.Energy; -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.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_Utility.filterValidMTEs; - -import java.util.ArrayList; -import java.util.Collections; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private final ArrayList mReplicatorDataOrbHatches = new ArrayList<>(); - private static final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 3); - private int mCasing = 0; - - public GregtechMTE_ElementalDuplicator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_ElementalDuplicator(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_ElementalDuplicator(this.mName); - } - - @Override - public String getMachineType() { - return "Replicator"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Produces Elemental Material from UU Matter") - .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 8 * Tier") - .addInfo("Maximum 1x of each bus/hatch.") - .addInfo("Requires circuit 1-16 in your Data Orb Repository") - .addInfo("depending on what Data Orb you want to prioritize") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 6, 9, true) - .addController("Top Center") - .addCasingInfoMin("Elemental Confinement Shell", 138, false) - .addCasingInfoMin("Matter Fabricator Casing", 24, false) - .addCasingInfoMin("Particle Containment Casing", 24, false) - .addCasingInfoMin("Matter Generation Coil", 24, false) - .addCasingInfoMin("High Voltage Current Capacitor", 20, false) - .addCasingInfoMin("Resonance Chamber III", 24, false) - .addCasingInfoMin("Modulator III", 16, false) - .addOtherStructurePart("Data Orb Repository", "1x", 1) - .addInputHatch("Any 1 dot hint", 1) - .addOutputBus("Any 1 dot hint", 1) - .addOutputHatch("Any 1 dot hint", 1) - .addEnergyHatch("Any 1 dot hint", 1) - .addMaintenanceHatch("Any 1 dot hint", 1) - .addMufflerHatch("Any 1 dot hint", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - - // h = Hatch - // c = Casing - - // a = MF Casing 1 - // b = Matter Gen Coil - - // d = Current Capacitor - // e = Particle - - // f = Resonance III - // g = Modulator III - - .addShape( - STRUCTURE_PIECE_MAIN, - (new String[][] { - { " ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccch~hccc", "ccchhhccc", " ccccccc ", - " ccccc ", " ccc " }, - { " cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", - " abfba ", " cac " }, - { " cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", - " e e ", " cec " }, - { " cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", - " e e ", " cec " }, - { " cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", - " abfba ", " cac " }, - { " ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccchhhccc", "ccchhhccc", " ccccccc ", - " ccccc ", " ccc " }, })) - .addElement('a', ofBlock(getCasingBlock4(), getCasingMeta6())) - .addElement('b', ofBlock(getCasingBlock4(), getCasingMeta7())) - .addElement('d', ofBlock(getCasingBlock2(), getCasingMeta2())) - .addElement('e', ofBlock(getCasingBlock2(), getCasingMeta3())) - .addElement('f', ofBlock(getCasingBlock3(), getCasingMeta4())) - .addElement('g', ofBlock(getCasingBlock3(), getCasingMeta5())) - .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement( - 'h', - lazy( - t -> ofChain( - buildHatchAdder(GregtechMTE_ElementalDuplicator.class) - .atLeast(InputHatch, OutputBus, OutputHatch, Maintenance, Muffler, Energy) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_ElementalDuplicator.class) - .hatchClass(GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.class) - .shouldReject(x -> x.mReplicatorDataOrbHatches.size() >= 1) - .adder(GregtechMTE_ElementalDuplicator::addDataOrbHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 4, 4, 0); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 4, 4, 0); - if (this.mInputHatches.size() != 1 || (this.mOutputBusses.size() != 1 && this.mOutputHatches.size() != 0) - || this.mEnergyHatches.size() != 1 - || this.mReplicatorDataOrbHatches.size() != 1) { - return false; - } - log("Casings: " + mCasing); - return aDidBuild && mCasing >= 138 && checkHatch(); - } - - @Override - public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, itemStack, 4, 4, 0, elementBudget, env, false, true); - } - - protected static int getCasingTextureIndex() { - return CASING_TEXTURE_ID; - } - - protected static Block getCasingBlock() { - return ModBlocks.blockCasings5Misc; - } - - protected static Block getCasingBlock2() { - return ModBlocks.blockSpecialMultiCasings; - } - - protected static Block getCasingBlock3() { - return ModBlocks.blockSpecialMultiCasings2; - } - - protected static Block getCasingBlock4() { - return ModBlocks.blockCasingsMisc; - } - - protected static int getCasingMeta() { - return 3; - } - - protected static int getCasingMeta2() { - return 12; - } - - protected static int getCasingMeta3() { - return 13; - } - - protected static int getCasingMeta4() { - return 2; - } - - protected static int getCasingMeta5() { - return 6; - } - - protected static int getCasingMeta6() { - return 9; - } - - protected static int getCasingMeta7() { - return 8; - } - - private boolean addDataOrbHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { - try { - return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); - } catch (Throwable t) { - t.printStackTrace(); - } - } - } - return false; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d == ForgeDirection.UP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAElementalDuplicatorActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAElementalDuplicator; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.replicatorRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2F) - .enablePerfectOverclock() - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void setupProcessingLogic(ProcessingLogic logic) { - super.setupProcessingLogic(logic); - for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder hatch : filterValidMTEs(mReplicatorDataOrbHatches)) { - ItemStack orb = hatch.getOrbByCircuit(); - logic.setSpecialSlotItem(orb); - break; - } - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mReplicatorDataOrbHatches.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public ArrayList getStoredInputs() { - ArrayList tItems = super.getStoredInputs(); - for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : filterValidMTEs(mReplicatorDataOrbHatches)) { - tItems.add(tHatch.getOrbByCircuit()); - } - tItems.removeAll(Collections.singleton(null)); - return tItems; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java deleted file mode 100644 index b887c74a47..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java +++ /dev/null @@ -1,287 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static 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.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.List; -import java.util.Objects; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.common.util.ForgeDirection; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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.FakeSyncWidget; - -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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_Recipe; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; - -public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_FrothFlotationCell(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_FrothFlotationCell(this.mName); - } - - @Override - public String getMachineType() { - return "Flotation Cell"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Process that milled ore!") - .addInfo("You can only ever process one type of material per controller") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 9, 7, true) - .addController("Front Center") - .addCasingInfoMin("Inconel Reinforced Casing", 68, false) - .addCasingInfoMin("Flotation Casing", 52, false) - .addInputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addOutputHatch("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDFrothFlotationCellActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDFrothFlotationCell; - } - - @Override - protected int getCasingTextureId() { - return TAE.getIndexFromPage(2, 1); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.flotationCellRecipes; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - new String[][] { { " ", " ", " X ", " X~X ", " X ", " ", " " }, - { " ", " F ", " FFF ", " FF FF ", " FFF ", " F ", " " }, - { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, - { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, - { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, - { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, - { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, - { " CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC " }, - { " CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC " }, }) - .addElement( - 'C', - buildHatchAdder(GregtechMTE_FrothFlotationCell.class) - .atLeast(InputBus, InputHatch, OutputHatch, Maintenance, Energy) - .casingIndex(getCasingTextureId()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) - .addElement('F', ofBlock(ModBlocks.blockSpecialMultiCasings, 9)) - .addElement('X', ofBlock(ModBlocks.blockCasings3Misc, 1)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 3, 3, 0) && mCasing >= 68 - 4 && checkHatch(); - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d == ForgeDirection.UP; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - /* - * Material checks Makes sure we can only ever use one type of material in this flotation cell. We used - * to depend on Alk's hash, but it's unreliable and user-hostile So we're using unlocalized name of - * material now. - */ - Material foundMaterial = FlotationRecipeHandler - .getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(recipe)); - String foundMaterialName = null; - if (foundMaterial != null) { - foundMaterialName = foundMaterial.getUnlocalizedName(); - } - - if (foundMaterialName == null) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - - // Set material locked for this controller - if (lockedMaterialName == null) { - lockedMaterialName = foundMaterialName; - } - - // Check material match - if (!Objects.equals(lockedMaterialName, foundMaterialName)) { - return SimpleCheckRecipeResult.ofFailure("machine_locked_to_different_recipe"); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - }.enablePerfectOverclock(); - } - - /* - * Handle NBT - */ - - private String lockedMaterialName = null; - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - if (lockedMaterialName != null) { - aNBT.setString("lockedMaterialName", lockedMaterialName); - } - super.setItemNBT(aNBT); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - if (lockedMaterialName != null) { - aNBT.setString("lockedMaterialName", lockedMaterialName); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("lockedMaterialName", Constants.NBT.TAG_STRING)) { - lockedMaterialName = aNBT.getString("lockedMaterialName"); - } - } - - @Override - public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { - if (stack.hasTagCompound() && stack.getTagCompound() - .hasKey("lockedMaterialName")) { - tooltip.add( - StatCollector.translateToLocal("tooltip.flotationCell.lockedTo") + " " - + StatCollector.translateToLocal( - stack.getTagCompound() - .getString("lockedMaterialName"))); - } - } - - @Override - public String[] getExtraInfoData() { - return new String[] { "Locked material: " + lockedMaterialName }; - } - - @Override - public boolean isRecipeLockingEnabled() { - return lockedMaterialName != null && !lockedMaterialName.equals(""); - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - super.addUIWidgets(builder, buildContext); - builder.widget(new FakeSyncWidget.StringSyncer(() -> lockedMaterialName, val -> lockedMaterialName = val)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java deleted file mode 100644 index 5bea6bb91f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ /dev/null @@ -1,525 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_RecipeConstants.LFTR_OUTPUT_POWER; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; -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_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.objects.GT_ItemStack; -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.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.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.nuclear.NUCLIDE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - protected int mFuelRemaining = 0; - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_NuclearReactor(final String aName) { - super(aName); - } - - @Override - public long maxEUStore() { - return (640000000L * (Math.min(16, this.mEnergyHatches.size()))) / 16L; - } - - @Override - public String getMachineType() { - return "Reactor"; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.liquidFluorineThoriumReactorRecipes; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") - .addInfo("Produces energy and new elements from Radioactive Beta Decay!") - .addInfo("Input LFTB and a molten salt as fuel, and match the 4 Buffered Dynamo Hatches:") - .addInfo("LFTR Fuel 1 (4 EV Hatches), LFTR Fuel 2 (4 IV Hatches), LFTR Fuel 3 (4 LuV Hatches)") - .addInfo("If using better hatches for a worse fuel, only 1 hatch will output EU") - .addInfo("Outputs U233 every 10 seconds, on average, while the reactor is running") - .addInfo("Check NEI to see the other 3 outputs - they differ between fuels") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(7, 4, 7, true) - .addController("Bottom Center") - .addCasingInfoMin("Hastelloy-N Reactor Casing", 27, false) - .addCasingInfoMin("Zeron-100 Reactor Shielding", 26, false) - .addInputHatch("Top or bottom layer edges", 1) - .addOutputHatch("Top or bottom layer edges", 1) - .addDynamoHatch("Top or bottom layer edges", 1) - .addMufflerHatch("Top 3x3", 2) - .addStructureInfo("All dynamos must be between EV and LuV tier.") - .addStructureInfo("All other hatches must be IV+ tier.") - .addStructureInfo("4x Output Hatches or 1x Output Hatch (ME), 1+ Input Hatches") - .addStructureInfo("4x Dynamo Hatches, 4x Mufflers") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public String[] getExtraInfoData() { - final String tRunning = (this.mMaxProgresstime > 0 ? "Reactor running" : "Reactor stopped"); - final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" - : "Needs Maintainance"); - - return new String[] { "Liquid Fluoride Thorium Reactor", tRunning, tMaintainance, - "Current Output: " + this.lEUt + " EU/t", "Fuel Remaining: " + this.mFuelRemaining + " Litres", - "Current Efficiency: " + (this.mEfficiency / 5) + "%", "Current Efficiency (Raw): " + (this.mEfficiency), - "It requires you to have 100% Efficiency." }; - } - - @Override - public boolean allowCoverOnSide(final ForgeDirection side, final GT_ItemStack aStack) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - boolean aWarmedUp = this.mEfficiency == this.getMaxEfficiency(null); - if (!aBaseMetaTileEntity.isActive() || !aWarmedUp) { - if (side == facing) { - if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder() - .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR_ACTIVE) - .extFacing() - .build() }; - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder() - .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR) - .extFacing() - .build() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; - } else if (aBaseMetaTileEntity.isActive() && aWarmedUp) { - if (side == facing) { - if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), - TextureFactory.builder() - .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR_ACTIVE) - .extFacing() - .build() }; - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), - TextureFactory.builder() - .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR) - .extFacing() - .build() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)) }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; - } - - public final boolean addNuclearReactorEdgeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo dynamo - && dynamo.getTierForStructure() >= 4 - && dynamo.getTierForStructure() <= 6) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input hatch - && hatch.getTierForStructure() >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output hatch - && hatch.getTierForStructure() >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public final boolean addNuclearReactorTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler hatch && hatch.getTierForStructure() >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { - { "CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC" }, - { "GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG" }, - { "GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG" }, - { "CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_NuclearReactor.class).atLeast(Maintenance) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_NuclearReactor.class).atLeast(InputHatch, OutputHatch) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) - .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_NuclearReactor.class).atLeast(Dynamo) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorEdgeList) - .hatchItemFilterAnd(t -> filterByMTETier(4, 6)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) - .addElement( - 'X', - buildHatchAdder(GregtechMTE_NuclearReactor.class).atLeast(Muffler) - .adder(GregtechMTE_NuclearReactor::addNuclearReactorTopList) - .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(12)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) - .addElement('O', ofBlock(ModBlocks.blockCasingsMisc, 12)) - .addElement('G', ofBlock(ModBlocks.blockCasingsMisc, 13)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { - if ((mOutputHatches.size() >= 3 || canDumpFluidToME()) && mInputHatches.size() >= 1 - && mDynamoHatches.size() == 4 - && mMufflerHatches.size() == 4) { - this.turnCasingActive(false); - return true; - } - } - return false; - } - - // Alk's Life Lessons from Greg. - /* - * [23:41:15] xdir and zdir are x2 and not x3 [23:41:26] thats you - * issue [23:44:33] mmm? [23:44:49] Should they be x3? [23:44:50] you - * just do a x2, what is for a 5x5 multiblock [23:45:01] x3 is for a 7x7 one [23:45:06] - * I have no idea what that value does, tbh.. [23:45:15] its the offset [23:45:23] - * Debugging checkMachine has been a pain and I usually trash designs that don't work straight up.. - * [23:45:28] it determines the horizontal middle of the multiblock [23:45:47] - * which is in your case THREE blocks away from the controller [23:45:51] Ahh - * [23:45:57] and not 2 [23:46:06] Noted, thanks :D - */ - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return true; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_NuclearReactor(this.mName); - } - - public boolean turnCasingActive(final boolean status) { - // TODO - if (this.mDynamoHatches != null) { - for (final GT_MetaTileEntity_Hatch_Dynamo hatch : this.mDynamoHatches) { - hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); - } - } - if (this.mMufflerHatches != null) { - for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { - hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); - } - } - if (this.mOutputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); - } - } - if (this.mInputHatches != null) { - for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); - } - } - if (this.mMaintenanceHatches != null) { - for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { - hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); - } - } - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - return GT_OverclockCalculator - .ofNoOverclock(recipe.getMetadataOrDefault(LFTR_OUTPUT_POWER, 0) * 4L, recipe.mDuration); - } - - @NotNull - @Override - public CheckRecipeResult process() { - CheckRecipeResult result = super.process(); - if (!result.wasSuccessful()) { - resetMultiProcessing(); - } - return result; - } - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - mFuelRemaining = 0; - int li2bef4 = 0; - FluidStack aFuelFluid = null; - for (FluidStack aFluidInput : recipe.mFluidInputs) { - if (!aFluidInput.getFluid() - .equals(NUCLIDE.Li2BeF4.getFluid())) { - aFuelFluid = aFluidInput; - break; - } - } - if (aFuelFluid != null) { - for (FluidStack fluidStack : inputFluids) { - if (fluidStack.isFluidEqual(aFuelFluid)) { - mFuelRemaining += fluidStack.amount; - } else if (fluidStack.getFluid() - .equals(NUCLIDE.Li2BeF4.getFluid())) { - li2bef4 += fluidStack.amount; - } - } - } - if (mFuelRemaining < 100) { - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - if (li2bef4 < 200) { - return SimpleCheckRecipeResult.ofFailure("no_li2bef4"); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - }; - } - - protected void resetMultiProcessing() { - this.mEfficiency = 0; - this.mLastRecipe = null; - stopMachine(ShutDownReasonRegistry.NONE); - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - // Warm up for 4~ minutes - if (mEfficiency < this.getMaxEfficiency(null)) { - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 2; - this.lEUt = 0; - return SimpleCheckRecipeResult.ofSuccess("warm_up"); - } - CheckRecipeResult result = super.checkProcessing(); - if (result.wasSuccessful()) { - // We produce EU, so we negate the value, if negative - if (lEUt < 0) { - lEUt = -lEUt; - } - } - return result; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public void explodeMultiblock() { - this.mInventory[1] = null; - long explodevalue; - for (final MetaTileEntity tTileEntity : this.mInputBusses) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mOutputBusses) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mInputHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mOutputHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - tTileEntity.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); - this.getBaseMetaTileEntity() - .doExplosion(explodevalue); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.getWorld().isRemote) { - if (aBaseMetaTileEntity.isActive()) { - // Set casings active if we're warmed up. - this.turnCasingActive(this.mEfficiency == this.getMaxEfficiency(null)); - } else { - this.turnCasingActive(false); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - // See if we're warmed up. - if (this.mEfficiency == this.getMaxEfficiency(null)) { - // Try output some Uranium-233 - if (MathUtils.randInt(1, 300) == 1) { - this.addOutput(ELEMENT.getInstance().URANIUM233.getFluidStack(MathUtils.randInt(1, 10))); - } - } - return super.onRunningTick(aStack); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mFuelRemaining", this.mFuelRemaining); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mFuelRemaining = aNBT.getInteger("mFuelRemaining"); - super.loadNBTData(aNBT); - } - - @Override - public boolean getDefaultHasMaintenanceChecks() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java deleted file mode 100644 index 8017ffbf47..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ /dev/null @@ -1,823 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -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 gregtech.common.items.ID_MetaTool_01.BRANCHCUTTER; -import static gregtech.common.items.ID_MetaTool_01.BUZZSAW_HV; -import static gregtech.common.items.ID_MetaTool_01.BUZZSAW_LV; -import static gregtech.common.items.ID_MetaTool_01.BUZZSAW_MV; -import static gregtech.common.items.ID_MetaTool_01.CHAINSAW_HV; -import static gregtech.common.items.ID_MetaTool_01.CHAINSAW_LV; -import static gregtech.common.items.ID_MetaTool_01.CHAINSAW_MV; -import static gregtech.common.items.ID_MetaTool_01.KNIFE; -import static gregtech.common.items.ID_MetaTool_01.POCKET_BRANCHCUTTER; -import static gregtech.common.items.ID_MetaTool_01.POCKET_KNIFE; -import static gregtech.common.items.ID_MetaTool_01.POCKET_MULTITOOL; -import static gregtech.common.items.ID_MetaTool_01.POCKET_SAW; -import static gregtech.common.items.ID_MetaTool_01.POCKET_WIRECUTTER; -import static gregtech.common.items.ID_MetaTool_01.SAW; -import static gregtech.common.items.ID_MetaTool_01.WIRECUTTER; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; - -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemShears; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; - -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 forestry.api.arboriculture.IToolGrafter; -import forestry.api.arboriculture.ITree; -import forestry.api.arboriculture.TreeManager; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Mods; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -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_ModHandler; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.VoidProtectionHelper; -import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.items.ID_MetaTool_01; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; - -public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - public static int CASING_TEXTURE_ID; - private static final int TICKS_PER_OPERATION = 100; - private static final int TOOL_DAMAGE_PER_OPERATION = 1; - private static final int TOOL_CHARGE_PER_OPERATION = 32; - - private int mCasing; - public static String mCasingName = "Sterile Farm Casing"; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); - } - - public GregtechMetaTileEntityTreeFarm(final String aName) { - super(aName); - CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityTreeFarm(this.mName); - } - - @Override - public String getMachineType() { - return "Tree Farm"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller block for the Tree Growth Simulator") - .addInfo("Farms and harvests trees using EU") - .addInfo("Place a sapling in the controller slot") - .addInfo("Place a tool in an input bus") - .addInfo("Different tools are required for different outputs") - .addInfo("Advanced tools multiply output amount") - .addInfo(" Logs: Saw (1x), Buzzsaw (2x), Chainsaw (4x)") - .addInfo(" Saplings: Branch Cutter (1x), Grafter (3x)") - .addInfo(" Leaves: Shears (1x), Wire Cutter (2x), Automatic Snips (4x)") - .addInfo(" Fruit: Knife (1x)") - .addInfo("Multiple tools can be used at the same time") - .addSeparator() - .addInfo("Work time is fixed at 5 seconds") - .addInfo("Energy input tier multiplies output further") - .addInfo("Output multiplier is equal to: 2*tier^2 - 2*tier + 5") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfoMin(mCasingName, 8, false) - .addInputBus("Any casing", 1) - .addStructureInfo( - EnumChatFormatting.YELLOW + "Stocking Input Busses and Crafting Input Busses/Buffers are not allowed!") - .addOutputBus("Any casing", 1) - .addEnergyHatch("Any casing", 1) - .addMaintenanceHatch("Any casing", 1) - .addMufflerHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCATreeFarmActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCATreeFarm; - } - - @Override - protected int getCasingTextureId() { - return CASING_TEXTURE_ID; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 8 && checkHatch(); - } - - @Override - public boolean addInputBusToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - // Tools from a stocking inout bus can not be damaged, this would cause an infinite durability exploit. - // Therefore disallow ME input bus. - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus_ME) return false; - return super.addInputBusToMachineList(aTileEntity, aBaseCasingIndex); - } - - @Override - public boolean supportsCraftingMEBuffer() { - return false; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public boolean supportsBatchMode() { - // Batch mode would not do anything, processing time is fixed at 100 ticks. - return false; - } - - @Override - public boolean isBatchModeEnabled() { - return false; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiTreeFarm; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntityTreeFarm.class) - .atLeast( - InputHatch, - OutputHatch, - InputBus, - OutputBus, - Maintenance, - Energy.or(TTEnergy), - Muffler) - .casingIndex(CASING_TEXTURE_ID) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 15)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - /* Processing logic. */ - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - if (aStack == null) return false; - if (isValidSapling(aStack)) return true; - /* - * In previous versions, a saw used to go in the controller slot. We do not want an update to stop processing of - * a machine set up like this. Instead, a sapling is placed in this slot at the start of the next operation. - */ - if (aStack.getItem() instanceof GT_MetaGenerated_Tool_01) return true; - return false; - } - - @Override - public RecipeMap getRecipeMap() { - // Only for NEI, not used in processing logic. - return GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes; - } - - /** - * Valid processing modes (types of output) for the Tree Growth Simulator. - */ - public enum Mode { - LOG, - SAPLING, - LEAVES, - FRUIT - } - - /** - * Edit this to change relative yields for different modes. For example, logs are output at 5 times the rate of - * saplings. - */ - private static final EnumMap modeMultiplier = new EnumMap<>(Mode.class); - static { - modeMultiplier.put(Mode.LOG, 5); - modeMultiplier.put(Mode.SAPLING, 1); - modeMultiplier.put(Mode.LEAVES, 2); - modeMultiplier.put(Mode.FRUIT, 1); - } - - /** - * Return the output multiplier for a given power tier. - * - * @param tier Power tier the machine runs on. - * @return Factor to multiply all outputs by. - */ - private static int getTierMultiplier(int tier) { - /* - * Where does this formula come from? [12:57 AM] boubou_19: i did. Basically Pandoro measured the output of a - * WA-ed farming station for each tier of WA, then i computed the Lagrange interpolating polynomial of his - * dataset, which gave this - */ - return (2 * (tier * tier)) - (2 * tier) + 5; - } - - /** - * Key of this map is the registry name of the sapling, followed by ":", and the sapling's metadata value. - *

- * The value of the map is a list of products by {@link Mode}. Products for some modes can be null if the tree does - * not produce anything in that mode (for example, it has no fruit). - */ - public static final HashMap> treeProductsMap = new HashMap<>(); - - @Override - public ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Override - @Nonnull - public CheckRecipeResult process() { - if (inputItems == null) { - inputItems = new ItemStack[0]; - } - if (inputFluids == null) { - inputFluids = new FluidStack[0]; - } - - ItemStack sapling = findSapling(); - if (sapling == null) return SimpleCheckRecipeResult.ofFailure("no_sapling"); - - EnumMap outputPerMode = getOutputsForSapling(sapling); - if (outputPerMode == null) { - // This should usually not be possible, outputs for all valid saplings should be defined. - Logger.INFO("No output found for sapling: " + sapling.getDisplayName()); - return SimpleCheckRecipeResult.ofFailure("no_output_for_sapling"); - } - - int tier = Math.max(1, GT_Utility.getTier(availableVoltage * availableAmperage)); - int tierMultiplier = getTierMultiplier(tier); - - List outputs = new ArrayList<>(); - for (Mode mode : Mode.values()) { - ItemStack output = outputPerMode.get(mode); - if (output == null) continue; // This sapling has no output in this mode. - - // Find a tool to use in this mode. - int toolMultiplier = useToolForMode(mode, false); - if (toolMultiplier < 0) continue; // No valid tool for this mode found. - - // Increase output by the relevant multipliers. - ItemStack out = output.copy(); - out.stackSize *= tierMultiplier * modeMultiplier.get(mode) * toolMultiplier; - outputs.add(out); - } - - if (outputs.isEmpty()) { - // No outputs can be produced using the tools we have available. - return SimpleCheckRecipeResult.ofFailure("no_tools"); - } - - outputItems = outputs.toArray(new ItemStack[0]); - - VoidProtectionHelper voidProtection = new VoidProtectionHelper().setMachine(machine) - .setItemOutputs(outputItems) - .build(); - if (voidProtection.isItemFull()) { - return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; - } - - duration = TICKS_PER_OPERATION; - calculatedEut = GT_Values.VP[tier]; - - for (Mode mode : Mode.values()) { - if (outputPerMode.get(mode) != null) { - useToolForMode(mode, true); - } - } - - return SimpleCheckRecipeResult.ofSuccess("growing_trees"); - } - }; - } - - /** - * Attempts to find a tool appropriate for the given mode, and damage/discharge it by one use. - * - * @param mode The mode to use. This specifies which tools are valid. - * @param shouldDamage if true, then the tool will have reduced durability/charge - */ - - private int useToolForMode(Mode mode, boolean shouldDamage) { - final ArrayList inputs = getStoredInputs(); - final int inputsSize = inputs.size(); - for (int i = inputsSize - 1; i >= 0; i--) { - ItemStack stack = inputs.get(i); - - int toolMultiplier = getToolMultiplier(stack, mode); - if (toolMultiplier < 0) { - continue; - } - boolean canDamage = shouldDamage - ? GT_ModHandler.damageOrDechargeItem(stack, TOOL_DAMAGE_PER_OPERATION, TOOL_CHARGE_PER_OPERATION, null) - : GT_ModHandler.damageOrDechargeItem(stack, 0, 0, null); - if (shouldDamage) { - if (!canDamage || GT_ModHandler.isElectricItem(stack) - && !GT_ModHandler.canUseElectricItem(stack, TOOL_CHARGE_PER_OPERATION)) { - depleteInput(stack); - addOutput(stack); - } - } - if (canDamage) { - return toolMultiplier; - } - } - return -1; - } - - /** - * Calculate output multiplier for a given tool and mode. - * - * @param toolStack The tool to use. - * @param mode The mode to use. - * @return Output multiplier for the given tool used in the given mode. If the tool is not appropriate for this - * mode, returns -1. - */ - public static int getToolMultiplier(ItemStack toolStack, Mode mode) { - Item tool = toolStack.getItem(); - int damage = toolStack.getItemDamage(); - switch (mode) { - case LOG: - if (tool instanceof GT_MetaGenerated_Tool_01) { - - if (damage == SAW.ID || damage == POCKET_SAW.ID || damage == POCKET_MULTITOOL.ID) { - return 1; - } - - if (damage == BUZZSAW_LV.ID || damage == BUZZSAW_MV.ID || damage == BUZZSAW_HV.ID) { - return 2; - } - - if (damage == CHAINSAW_LV.ID || damage == CHAINSAW_MV.ID || damage == CHAINSAW_HV.ID) { - return 4; - } - } - break; - - case SAPLING: - if (tool instanceof GT_MetaGenerated_Tool_01 - && (damage == BRANCHCUTTER.ID || damage == POCKET_BRANCHCUTTER.ID - || damage == POCKET_MULTITOOL.ID)) { - return 1; - } - if (tool instanceof IToolGrafter && tool.isDamageable()) { - return 3; - } - break; - - case LEAVES: - // Do not allow unbreakable tools. Operation should have a running cost. - if (tool instanceof ItemShears && tool.isDamageable()) { - return 1; - } - if (tool instanceof GT_MetaGenerated_Tool_01) { - if (damage == POCKET_MULTITOOL.ID) { - return 1; - } - if (damage == WIRECUTTER.ID || damage == POCKET_WIRECUTTER.ID) { - return 2; - } - } - if (tool instanceof MetaGeneratedGregtechTools) { - if (toolStack.getItemDamage() == MetaGeneratedGregtechTools.ELECTRIC_SNIPS) { - return 4; - } - } - break; - - case FRUIT: - if (tool instanceof GT_MetaGenerated_Tool_01 - && (damage == KNIFE.ID || damage == POCKET_KNIFE.ID || damage == POCKET_MULTITOOL.ID)) { - return 1; - } - break; - } - - // No valid tool was found. - return -1; - } - - /* Handling saplings. */ - - /** - * Finds a valid sapling from input buses, and places it into the controller slot. - * - * @return The sapling that was found (now in the controller slot). - */ - private ItemStack findSapling() { - ItemStack controllerSlot = getControllerSlot(); - - if (isValidSapling(controllerSlot)) { - return controllerSlot; - } - - if (controllerSlot != null) { - // Non-sapling item in controller slot. This could be a saw from an older version of the TGS. - // We first try to swap it with a sapling from an input bus to not interrupt existing setups. - if (!legacyToolSwap()) { - // Swap failed, output whatever is blocking the slot. - addOutput(controllerSlot); - mInventory[1] = null; - } - } - - // Here controller slot is empty, find a valid sapling to use. - for (ItemStack stack : getStoredInputs()) { - if (isValidSapling(stack)) { - mInventory[1] = stack.splitStack(1); - return mInventory[1]; - } - } - - // No saplings were found. - return null; - } - - /** - * In previous versions, the saw used to be placed in the controller slot and the sapling into an input bus. We do - * not want to break existing setups like this, so we attempt to swap the two if possible. - * - * @return True on success, false otherwise. - */ - private boolean legacyToolSwap() { - ItemStack controllerSlot = getControllerSlot(); - if (controllerSlot == null || !(controllerSlot.getItem() instanceof GT_MetaGenerated_Tool_01)) return false; - - for (GT_MetaTileEntity_Hatch_InputBus inputBus : filterValidMTEs(mInputBusses)) { - ItemStack[] inventory = inputBus.getRealInventory(); - for (int slot = 0; slot < inventory.length; ++slot) { - if (isValidSapling(inventory[slot])) { - // Do the swap. - mInventory[1] = inventory[slot]; - inventory[slot] = controllerSlot; - inputBus.updateSlots(); - return true; - } - } - } - return false; - } - - /** - * Check if an ItemStack is a sapling that can be farmed. - * - * @param stack An ItemStack. - * @return True if stack is a valid sapling that can be farmed. - */ - private boolean isValidSapling(ItemStack stack) { - if (stack == null) return false; - String registryName = Item.itemRegistry.getNameForObject(stack.getItem()); - return treeProductsMap.containsKey(registryName + ":" + stack.getItemDamage()) - || "Forestry:sapling".equals(registryName); - } - - /** - * Get a list of possible outputs for a sapling, for each mode. This is either recovered from - * {@link #treeProductsMap}, or generated from stats of Forestry saplings. - * - * @param sapling A sapling to farm. - * @return A map of outputs for each mode. Outputs for some modes might be null. - */ - private static EnumMap getOutputsForSapling(ItemStack sapling) { - String registryName = Item.itemRegistry.getNameForObject(sapling.getItem()); - if ("Forestry:sapling".equals(registryName)) { - return getOutputsForForestrySapling(sapling); - } else { - return treeProductsMap.get(registryName + ":" + sapling.getItemDamage()); - } - } - - /** - * Calculate outputs for Forestry saplings. Default amounts stored in {@link #treeProductsMap} are adjusted based - * the genetics of the input sapling. - *

- * Relevant stats: - *

    - *
  • height, girth: Affects log output.
  • - *
  • fertility (called Saplings in game): Affects sapling output.
  • - *
  • yield: Affects fruit output.
  • - *
- * See {@link forestry.core.genetics.alleles.EnumAllele} for detailed numeric values for each allele. - * - * @param sapling A sapling to farm. Must be a Forestry sapling with a valid genome. - * @return A map of outputs for each mode. Outputs for some modes might be null. - */ - private static EnumMap getOutputsForForestrySapling(ItemStack sapling) { - ITree tree = TreeManager.treeRoot.getMember(sapling); - if (tree == null) return null; - - String speciesUUID = tree.getIdent(); - - EnumMap defaultMap = treeProductsMap.get("Forestry:sapling:" + speciesUUID); - if (defaultMap == null) return null; - - // We need to make a new map so that we don't modify the stored amounts of outputs. - EnumMap adjustedMap = new EnumMap<>(Mode.class); - - ItemStack log = defaultMap.get(Mode.LOG); - if (log != null) { - double height = Math.max( - 3 * (tree.getGenome() - .getHeight() - 1), - 0) + 1; - double girth = tree.getGenome() - .getGirth(); - - log = log.copy(); - log.stackSize = (int) (log.stackSize * height * girth); - adjustedMap.put(Mode.LOG, log); - } - - ItemStack saplingOut = defaultMap.get(Mode.SAPLING); - if (saplingOut != null) { - // Lowest = 0.01 ... Average = 0.05 ... Highest = 0.3 - double fertility = tree.getGenome() - .getFertility() * 10; - - // Return a copy of the *input* sapling, retaining its genetics. - int stackSize = Math.max(1, (int) (saplingOut.stackSize * fertility)); - saplingOut = sapling.copy(); - saplingOut.stackSize = stackSize; - adjustedMap.put(Mode.SAPLING, saplingOut); - } - - ItemStack leaves = defaultMap.get(Mode.LEAVES); - if (leaves != null) { - adjustedMap.put(Mode.LEAVES, leaves.copy()); - } - - ItemStack fruit = defaultMap.get(Mode.FRUIT); - if (fruit != null) { - // Lowest = 0.025 ... Average = 0.2 ... Highest = 0.4 - double yield = tree.getGenome() - .getYield() * 10; - - fruit = fruit.copy(); - fruit.stackSize = (int) (fruit.stackSize * yield); - adjustedMap.put(Mode.FRUIT, fruit); - } - - return adjustedMap; - } - - /* Recipe registration. */ - - /** - * Registers outputs for a sapling. This method assumes that output in mode SAPLING is the same as the input - * sapling. Output amount is further modified by mode, machine tier, and tool used. Recipes are added in - * {@link gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_TreeFarm}. - * - * @param sapling The input sapling to farm, and also the output in mode SAPLING. - * @param log ItemStack to output in mode LOG. - * @param leaves ItemStack to output in mode LEAVES. - * @param fruit ItemStack to output in mode FRUIT. - */ - public static void registerTreeProducts(ItemStack sapling, ItemStack log, ItemStack leaves, ItemStack fruit) { - registerTreeProducts(sapling, log, sapling, leaves, fruit); - } - - /** - * Registers outputs for a sapling. Output amount is further modified by mode, machine tier, and tool used. Recipes - * are added in {@link gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_TreeFarm}. - * - * @param saplingIn The input sapling to farm. - * @param log ItemStack to output in mode LOG. - * @param saplingOut ItemStack to output in mode SAPLING. - * @param leaves ItemStack to output in mode LEAVES. - * @param fruit ItemStack to output in mode FRUIT. - */ - public static void registerTreeProducts(ItemStack saplingIn, ItemStack log, ItemStack saplingOut, ItemStack leaves, - ItemStack fruit) { - String key = Item.itemRegistry.getNameForObject(saplingIn.getItem()) + ":" + saplingIn.getItemDamage(); - EnumMap map = new EnumMap<>(Mode.class); - if (log != null) map.put(Mode.LOG, log); - if (saplingOut != null) map.put(Mode.SAPLING, saplingOut); - if (leaves != null) map.put(Mode.LEAVES, leaves); - if (fruit != null) map.put(Mode.FRUIT, fruit); - treeProductsMap.put(key, map); - - if (!addFakeRecipeToNEI(saplingIn, log, saplingOut, leaves, fruit)) { - Logger.INFO("Registering NEI fake recipe for " + key + " failed!"); - } - } - - /** - * For Forestry trees, the output amounts depend on the genetics of the sapling. Here we register only the types of - * items to output. In {@link #getOutputsForForestrySapling(ItemStack)} these outputs are then multiplied according - * to the stats of the real sapling that is in the controller slot. - */ - public static void registerForestryTree(String speciesUID, ItemStack sapling, ItemStack log, ItemStack leaves, - ItemStack fruit) { - String key = "Forestry:sapling:" + speciesUID; - EnumMap map = new EnumMap<>(Mode.class); - map.put(Mode.LOG, log); - map.put(Mode.SAPLING, sapling); - map.put(Mode.LEAVES, leaves); - map.put(Mode.FRUIT, fruit); - treeProductsMap.put(key, map); - - // In the NEI recipe we want to display outputs adjusted for the default genetics of this tree type. - // To do this we use the same method as when calculating real outputs. - map = getOutputsForForestrySapling(sapling); - if (map == null) { - Logger.INFO("Could not create Forestry tree output map for " + speciesUID); - return; - } - addFakeRecipeToNEI( - sapling, - map.get(Mode.LOG), - map.get(Mode.SAPLING), - map.get(Mode.LEAVES), - map.get(Mode.FRUIT)); - } - - /** - * This array is used to get the rotating display of items in NEI showing all possible tools for a given mode. - */ - private static final ItemStack[][] altToolsForNEI; - static { - GT_MetaGenerated_Tool toolInstance = GT_MetaGenerated_Tool_01.INSTANCE; - altToolsForNEI = new ItemStack[][] { - // Mode.LOG - { toolInstance.getToolWithStats(SAW.ID, 1, null, null, null), - toolInstance.getToolWithStats(POCKET_SAW.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.BUZZSAW_LV.ID, 1, null, null, null), - toolInstance.getToolWithStats(CHAINSAW_LV.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.BUZZSAW_MV.ID, 1, null, null, null), - toolInstance.getToolWithStats(CHAINSAW_MV.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.BUZZSAW_HV.ID, 1, null, null, null), - toolInstance.getToolWithStats(CHAINSAW_HV.ID, 1, null, null, null), }, - // Mode.SAPLING - { toolInstance.getToolWithStats(ID_MetaTool_01.BRANCHCUTTER.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.POCKET_BRANCHCUTTER.ID, 1, null, null, null), - GT_ModHandler.getModItem(Mods.Forestry.ID, "grafter", 1, 0), }, - // Mode.LEAVES - { new ItemStack(Items.shears), - toolInstance.getToolWithStats(ID_MetaTool_01.WIRECUTTER.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.POCKET_WIRECUTTER.ID, 1, null, null, null), - MetaGeneratedGregtechTools.getInstance() - .getToolWithStats(MetaGeneratedGregtechTools.ELECTRIC_SNIPS, 1, null, null, null), }, - // Mode.FRUIT - { toolInstance.getToolWithStats(ID_MetaTool_01.KNIFE.ID, 1, null, null, null), - toolInstance.getToolWithStats(ID_MetaTool_01.POCKET_KNIFE.ID, 1, null, null, null), } }; - } - - /** - * Add a recipe for this tree to NEI. These recipes are only used in NEI, they are never used for processing logic. - * - * @return True if the recipe was added successfully. - */ - public static boolean addFakeRecipeToNEI(ItemStack saplingIn, ItemStack log, ItemStack saplingOut, ItemStack leaves, - ItemStack fruit) { - int recipeCount = GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.getAllRecipes() - .size(); - - // Sapling goes into the "special" slot. - ItemStack specialStack = saplingIn.copy(); - specialStack.stackSize = 0; - - /* - * Calculate the correct amount of outputs for each mode. The amount displayed in NEI should take into account - * the mode multiplier, but not tool/tier multipliers as those can change dynamically. If the sapling has an - * output in this mode, also add the tools usable for this mode as inputs. - */ - ItemStack[][] inputStacks = new ItemStack[Mode.values().length][]; - ItemStack[] outputStacks = new ItemStack[Mode.values().length]; - - for (Mode mode : Mode.values()) { - ItemStack output = switch (mode) { - case LOG -> log; - case SAPLING -> saplingOut; - case LEAVES -> leaves; - case FRUIT -> fruit; - }; - if (output != null) { - int ordinal = mode.ordinal(); - inputStacks[ordinal] = altToolsForNEI[ordinal]; - outputStacks[ordinal] = output.copy(); - outputStacks[ordinal].stackSize *= modeMultiplier.get(mode); - } - } - - Logger.INFO( - "Adding Tree Growth Simulation NEI recipe for " + specialStack.getDisplayName() - + " -> " - + ItemUtils.getArrayStackNames(outputStacks)); - - GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.addFakeRecipe( - false, - new GT_Recipe.GT_Recipe_WithAlt( - false, - null, // All inputs are taken from aAtl argument. - outputStacks, - specialStack, - null, - null, - null, - TICKS_PER_OPERATION, - 0, - recipeCount, // special value, also sorts recipes correctly in order of addition. - inputStacks)); - - return GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.getAllRecipes() - .size() > recipeCount; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java deleted file mode 100644 index 506a68ea12..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ /dev/null @@ -1,233 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -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.minecraftforge.common.util.ForgeDirection; - -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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_AlloyBlastSmelter - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mMode = 0; - private boolean isUsingControllerCircuit = false; - private static Item circuit; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); - } - - @Override - public String getMachineType() { - return "Fluid Alloy Cooker"; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (aNBT.hasKey("isBussesSeparate")) { - inputSeparation = aNBT.getBoolean("isBussesSeparate"); - } - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Alloy Blast Smelter") - .addInfo("Allows Complex GT++ alloys to be created") - .addInfo("Accepts only one Energy Hatch") - .addInfo("Circuit for recipe goes in the Input Bus or GUI slot") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, true) - .addController("Bottom Center") - .addCasingInfoMin("Blast Smelter Casings", 5, false) - .addCasingInfoMin("Blast Smelter Heat Containment Coils", 16, false) - .addInputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, - { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_AlloyBlastSmelter.class) - .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(15)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 15)))) - .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 14)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 3, 0) && mCasing >= 5 && mEnergyHatches.size() == 1 && checkHatch(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_INDUCTION_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDAlloyBlastSmelterActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDAlloyBlastSmelter; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(15); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.alloyBlastSmelterRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - if (this.getBaseMetaTileEntity() - .isServerSide()) { - // Get Controller Circuit - if (circuit == null) { - circuit = GT_Utility.getIntegratedCircuit(0) - .getItem(); - } - if (aStack != null && aStack.getItem() == circuit) { - this.mMode = aStack.getItemDamage(); - return this.isUsingControllerCircuit = true; - } else { - if (aStack == null) { - this.isUsingControllerCircuit = false; - return true; // Allowed empty - } - Logger.WARNING("Not circuit in GUI inputs."); - return this.isUsingControllerCircuit = false; - } - } - Logger.WARNING("No Circuit, clientside."); - return this.isUsingControllerCircuit = false; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic(); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - inputSeparation = !inputSeparation; - GT_Utility.sendChatToPlayer( - aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiABS; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public boolean supportsInputSeparation() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java deleted file mode 100644 index c85e406b6c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ /dev/null @@ -1,338 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; - -import org.jetbrains.annotations.NotNull; - -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.SoundResource; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.item.chemistry.IonParticles; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Cyclotron(int aID, String aName, String aNameRegional, int tier) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Cyclotron(String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Particle Accelerator"; - } - - public int tier() { - return 5; - } - - @Override - public long maxEUStore() { - return 1800000000L; - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Cyclotron(this.mName); - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return side != getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { - { " ", " hhh ", " hh hh ", " h h ", - " h h ", " h h ", " h h ", " h h ", - " h h ", " h h ", " h h ", " h h ", - " hh hh ", " hhh ", " ", }, - { " hhh ", " hhccchh ", " hcchhhcch ", " hchh hhch ", - " hch hch ", " hch hch ", "hch hch", "hch hch", - "hch hch", " hch hch ", " hch hch ", " hchh hhch ", - " hcch~hcch ", " hhccchh ", " hhh ", }, - { " ", " hhh ", " hh hh ", " h h ", - " h h ", " h h ", " h h ", " h h ", - " h h ", " h h ", " h h ", " h h ", - " hh hh ", " hhh ", " ", } })) - .addElement( - 'h', - buildHatchAdder(GregtechMetaTileEntity_Cyclotron.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) - .casingIndex(44) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('c', ofBlock(getCyclotronCoil(), getCyclotronCoilMeta())) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 7, 1, 12); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 7, 1, 12, elementBudget, env, false, true); - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.GT_MACHINES_FUSION_LOOP.resourceLocation; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 7, 1, 12) && mCasing >= 40 && checkHatch(); - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - public int getCasingMeta() { - return 10; - } - - public Block getCyclotronCoil() { - return ModBlocks.blockCasings2Misc; - } - - public int getCyclotronCoilMeta() { - return 9; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Super Magnetic Speed Shooter") - .addSeparator() - .addInfo("Particles are accelerated over 186 revolutions to 80% light speed") - .addInfo("Can produce a continuous beam current of 2.2 mA at 590 MeV") - .addInfo("Which will be extracted from the Isochronous Cyclotron") - .addSeparator() - .addInfo("Consists of the same layout as a Fusion Reactor") - .addInfo("Any external casing can be a hatch/bus, unlike Fusion") - .addInfo("Cyclotron Machine Casings around Cyclotron Coil Blocks") - .addInfo("All Hatches must be IV or better") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .addCasingInfoMin("Cyclotron Machine Casings", 40, false) - .addCasingInfoMin("Cyclotron Coil", 32, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return getIconOverlay(); - } - - @Override - protected IIconContainer getInactiveOverlay() { - return getIconOverlay(); - } - - @Override - protected int getCasingTextureId() { - return 44; - } - - public IIconContainer getIconOverlay() { - if (this.getBaseMetaTileEntity() - .isActive()) { - return TexturesGtBlock.Overlay_MatterFab_Active_Animated; - } - return TexturesGtBlock.Overlay_MatterFab_Animated; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.cyclotronRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - public CheckRecipeResult process() { - CheckRecipeResult result = super.process(); - if (result.wasSuccessful()) { - for (ItemStack s : outputItems) { - if (s != null) { - if (s.getItem() instanceof IonParticles) { - long aCharge = IonParticles.getChargeState(s); - if (aCharge == 0) { - IonParticles.setChargeState( - s, - MathUtils.getRandomFromArray( - new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, - -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 5, 5, 5, 6, 6 })); - } - } - } - } - } - return result; - } - }; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (this.mOutputBusses.size() > 0) { - for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) { - if (g != null) { - for (ItemStack s : g.mInventory) { - if (s != null) { - if (s.getItem() instanceof IonParticles) { - long aCharge = IonParticles.getChargeState(s); - if (aCharge == 0) { - IonParticles.setChargeState( - s, - MathUtils.getRandomFromArray( - new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, - -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 5, 5, 5, 6, 6 })); - } - } - } - } - } - } - } - return super.onRunningTick(aStack); - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiCyclotron; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public String[] getExtraInfoData() { - String tier = tier() == 5 ? "I" : "II"; - float plasmaOut = 0; - int powerRequired = 0; - if (this.mLastRecipe != null) { - powerRequired = this.mLastRecipe.mEUt; - if (this.mLastRecipe.getFluidOutput(0) != null) { - plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; - } - } - - return new String[] { "COMET - Compact Cyclotron MK " + tier, "EU Required: " + powerRequired + "EU/t", - "Stored EU: " + this.getEUVar() + " / " + maxEUStore() }; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } - - @Override - public boolean getDefaultHasMaintenanceChecks() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java deleted file mode 100644 index 0133c8b301..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ /dev/null @@ -1,488 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandomFishable; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -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.FishPondFakeRecipe; -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; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; - -public class GregtechMetaTileEntity_IndustrialFishingPond extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private boolean isUsingControllerCircuit = false; - private static final Item circuit = GT_Utility.getIntegratedCircuit(0) - .getItem(); - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - private static final Class cofhWater; - - static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); - } - - public GregtechMetaTileEntity_IndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialFishingPond(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialFishingPond(this.mName); - } - - @Override - public String getMachineType() { - return "Fish Trap"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Fishing Pond") - .addInfo("Can process (Tier + 1) * 2 recipes") - .addInfo("Put a numbered circuit into the input bus.") - .addInfo("Circuit 14 for Fish") - .addInfo("Circuit 15 for Junk") - .addInfo("Circuit 16 for Treasure") - .addInfo("Need to be filled with water.") - .addInfo("Will automatically fill water from input hatch.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 3, 9, true) - .addController("Front Center") - .addCasingInfoMin("Aquatic Casings", 64, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { - { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", - "X X", "XXXXXXXXX" }, - { "XXXX~XXXX", "X X", "X X", "X X", "X X", "X X", "X X", - "X X", "XXXXXXXXX" }, - { "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", - "XXXXXXXXX", "XXXXXXXXX" }, })) - .addElement( - 'X', - buildHatchAdder(GregtechMetaTileEntity_IndustrialFishingPond.class) - .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 4, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 4, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 4, 1, 0) && mCasing >= 64 && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.fishPondRecipes; - } - - @Override - protected boolean filtersFluid() { - return false; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - ItemStack controllerStack = getControllerSlot(); - if (controllerStack != null) { - if (controllerStack.getItem() == circuit) { - this.isUsingControllerCircuit = true; - this.mMode = controllerStack.getItemDamage(); - } else { - this.isUsingControllerCircuit = false; - } - } else { - this.isUsingControllerCircuit = false; - } - if (!hasGenerateRecipes) { - generateRecipes(); - } - if (!checkForWater()) { - return SimpleCheckRecipeResult.ofFailure("no_water"); - } - ItemStack[] tItemInputs = getStoredInputs().toArray(new ItemStack[0]); - FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); - - if (!isUsingControllerCircuit && tItemInputs.length == 0) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - - long tEnergy = getMaxInputEnergy(); - - getCircuit(tItemInputs); - - ItemStack[] mFishOutput = generateLoot(this.mMode); - mFishOutput = removeNulls(mFishOutput); - GT_Recipe g = new GT_Recipe( - true, - new ItemStack[] {}, - mFishOutput, - null, - new int[] {}, - tFluidInputs, - null, - 200, - 16, - 0); - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(g.mEUt) - .setEUt(tEnergy) - .setDuration(g.mDuration); - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(g) - .setItemInputs(tItemInputs) - .setFluidInputs(tFluidInputs) - .setAvailableEUt(tEnergy) - .setMaxParallel(getMaxParallelRecipes()) - .setConsumption(true) - .setOutputCalculation(true) - .setMachine(this) - .enableBatchMode(batchMode ? 128 : 1) - .setCalculator(calculator); - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = null; - updateSlots(); - - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Override - public int getMaxParallelRecipes() { - return (2 * (GT_Utility.getTier(this.getMaxInputVoltage()) + 1)); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta() { - return 0; - } - - public int getCasingTextureIndex() { - return TAE.GTPP_INDEX(32); - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - - final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; - final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; h++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (isNotStaticWater(tBlock, tMeta)) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = Blocks.water; - aBaseMetaTileEntity.getWorld() - .setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, - fluidUsed); - } - } - } - } - } - tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { - ++tAmount; - } - } - } - } - - return tAmount >= 60; - } - - private boolean isNotStaticWater(Block block, byte meta) { - return block == Blocks.air || block == Blocks.flowing_water - || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) - || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); - } - - private static AutoMap> categories = new AutoMap<>(); - private static AutoMap categoryFish = new AutoMap<>(); - private static AutoMap categoryJunk = new AutoMap<>(); - private static AutoMap categoryLoot = new AutoMap<>(); - private static boolean hasGenerateRecipes = false; - private int mMode = 14; - private int mMax = 8; - - private void generateRecipes() { - if (hasGenerateRecipes) return; - - categories.put(categoryFish); - categories.put(categoryJunk); - categories.put(categoryLoot); - for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { - categoryFish.put(h); - } - for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { - categoryJunk.put(h); - } - for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { - categoryLoot.put(h); - } - hasGenerateRecipes = true; - } - - private int getCircuit(ItemStack[] t) { - if (!this.isUsingControllerCircuit) { - for (ItemStack j : t) { - if (j.getItem() == GT_Utility.getIntegratedCircuit(0) - .getItem()) { - // Fish - if (j.getItemDamage() == 14) { - mMax = 8 + (this.getMaxParallelRecipes() - 2); - this.mMode = 14; - break; - } - // Junk - else if (j.getItemDamage() == 15) { - this.mMode = 15; - mMax = 4; - break; - } - // Loot - else if (j.getItemDamage() == 16) { - this.mMode = 16; - mMax = 4; - break; - } else { - this.mMode = 0; - mMax = 0; - break; - } - } else { - this.mMode = 0; - mMax = 0; - break; - } - } - } - return this.mMode; - } - - // reflection map - private static Map reflectiveFishMap = new HashMap<>(); - - private ItemStack reflectiveFish(WeightedRandomFishable y) { - if (reflectiveFishMap.containsKey(y)) { - return reflectiveFishMap.get(y); - } - ItemStack t; - try { - t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b") - .get(y); - ItemStack k = ItemUtils.getSimpleStack(t, 1); - reflectiveFishMap.put(y, k); - return t; - } catch (IllegalArgumentException | IllegalAccessException e) {} - return null; - } - - private ItemStack[] generateLoot(int mode) { - ItemStack[] mFishOutput = new ItemStack[this.mMax]; - if (this.mMode == 14) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryFish.values()) { - if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 15) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryJunk.values()) { - if (MathUtils.randInt(0, 100) <= 1) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 16) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryLoot.values()) { - if (MathUtils.randInt(0, 1000) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else { - mFishOutput = null; - } - return mFishOutput; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java deleted file mode 100644 index 520d52c9c5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java +++ /dev/null @@ -1,366 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gregtech.api.recipe.check.SimpleCheckRecipeResult; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IndustrialRockBreaker extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_IndustrialRockBreaker(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_IndustrialRockBreaker(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialRockBreaker(this.mName); - } - - @Override - public String getMachineType() { - return "Rock Breaker"; - } - - private static final String casingBaseName = GT_LanguageManager.getTranslation("gtplusplus.blockcasings.2.0.name"); - private static final String casingMiddleName = GT_LanguageManager - .getTranslation("gtplusplus.blockcasings.2.11.name"); - private static final String anyBaseCasing = "Any " + casingBaseName; - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Industrial Rock Breaker") - .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 8") - .addInfo("Circuit goes in the GUI slot") - .addInfo("1 = cobble, 2 = stone, 3 = obsidian") - .addInfo("Needs Water and Lava in input hatch") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 4, 3, true) - .addController("Bottom Center") - .addCasingInfoMin(casingBaseName, 9, false) - .addCasingInfoExactly(casingMiddleName, 16, false) - .addInputBus(anyBaseCasing, 1) - .addInputHatch(anyBaseCasing, 1) - .addOutputBus(anyBaseCasing, 1) - .addEnergyHatch(anyBaseCasing, 1) - .addMaintenanceHatch(anyBaseCasing, 1) - .addMufflerHatch(anyBaseCasing, 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, - { "C~C", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_IndustrialRockBreaker.class) - .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(16)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)))) - .addElement('H', ofBlock(ModBlocks.blockCasings2Misc, 11)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - boolean aCheckPiece = checkPiece(mName, 1, 3, 0); - boolean aCasingCount = mCasing >= 9; - boolean aCheckHatch = checkHatch(); - log("" + aCheckPiece + ", " + aCasingCount + ", " + aCheckHatch); - return aCheckPiece && aCasingCount && aCheckHatch; - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_INDUCTION_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAIndustrialRockBreakerActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAIndustrialRockBreaker; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(16); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.rockBreakerFakeRecipes; - } - - @Override - protected boolean filtersFluid() { - return false; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - private static GT_Recipe sRecipe_Cobblestone; - private static GT_Recipe sRecipe_SmoothStone; - private static GT_Recipe sRecipe_Redstone; - - private static void generateRecipes() { - sRecipe_Cobblestone = new GT_Recipe( - false, - new ItemStack[] { GT_Utility.getIntegratedCircuit(1) }, - new ItemStack[] { ItemUtils.getSimpleStack(Blocks.cobblestone) }, - null, - new int[] { 10000 }, - null, - null, - 16, - 32, - 0); - sRecipe_SmoothStone = new GT_Recipe( - false, - new ItemStack[] { GT_Utility.getIntegratedCircuit(2) }, - new ItemStack[] { ItemUtils.getSimpleStack(Blocks.stone) }, - null, - new int[] { 10000 }, - null, - null, - 16, - 32, - 0); - sRecipe_Redstone = new GT_Recipe( - false, - new ItemStack[] { GT_Utility.getIntegratedCircuit(3), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) }, - new ItemStack[] { ItemUtils.getSimpleStack(Blocks.obsidian) }, - null, - new int[] { 10000 }, - null, - null, - 128, - 32, - 0); - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - ArrayList aFluids = this.getStoredFluids(); - if (aFluids.isEmpty()) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - - boolean aHasWater = false; - boolean aHasLava = false; - for (FluidStack aFluid : aFluids) { - if (aFluid.getFluid() == FluidRegistry.WATER) { - aHasWater = true; - } else if (aFluid.getFluid() == FluidRegistry.LAVA) { - aHasLava = true; - } - } - ArrayList aItems = this.getStoredInputs(); - boolean aHasRedstone = false; - if (!aItems.isEmpty()) { - for (ItemStack aItem : aItems) { - if (GT_Utility - .areStacksEqual(aItem, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) { - aHasRedstone = true; - break; - } - } - } - - if (!aHasWater) { - return SimpleCheckRecipeResult.ofFailure("no_water"); - } - if (!aHasLava) { - return SimpleCheckRecipeResult.ofFailure("no_lava"); - } - ItemStack aGuiCircuit = this.getControllerSlot(); - if (!ItemUtils.isControlCircuit(aGuiCircuit)) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - - if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { - generateRecipes(); - } - - int aCircuit = aGuiCircuit.getItemDamage(); - - GT_Recipe tRecipe = null; - switch (aCircuit) { - case 1 -> tRecipe = sRecipe_Cobblestone; - case 2 -> tRecipe = sRecipe_SmoothStone; - case 3 -> { - if (aHasRedstone) { - tRecipe = sRecipe_Redstone; - } - } - } - - if (tRecipe == null) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[0]); - FluidStack[] aFluidInputs = new FluidStack[] {}; - - long tEnergy = getMaxInputEnergy(); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe) - .setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs) - .setAvailableEUt(tEnergy) - .setMaxParallel(getMaxParallelRecipes()) - .setConsumption(true) - .setOutputCalculation(true) - .setEUtModifier(0.75F) - .setMachine(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt) - .setEUt(tEnergy) - .setDuration(tRecipe.mDuration) - .setEUtDiscount(0.75F) - .setSpeedBoost(1F / 3F) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplierDouble())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - return CheckRecipeResultRegistry.SUCCESSFUL; - - } - - @Override - public int getMaxParallelRecipes() { - return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public ArrayList getStoredInputs() { - ArrayList aInputs = super.getStoredInputs(); - if (this.getControllerSlot() != null) { - aInputs.add(this.getControllerSlot()); - } - return aInputs; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java deleted file mode 100644 index 96a477bb26..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java +++ /dev/null @@ -1,524 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -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.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_Utility.filterValidMTEs; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.AirIntake; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.google.common.collect.ImmutableMap; -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 gregtech.api.enums.GT_Values; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -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.recipe.check.SimpleCheckRecipeResult; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.item.chemistry.RocketFuels; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_LargeRocketEngine - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected int fuelConsumption; - protected int fuelValue; - protected int fuelRemaining; - protected int freeFuelTicks = 0; - protected int euProduction = 0; - protected boolean boostEu; - - public static String mLubricantName = "Carbon Dioxide"; - public static String mCoolantName = "Liquid Hydrogen"; - - public static String mCasingName = "Turbodyne Casing"; - public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; - public static String mGearboxName = "Inconel Reinforced Casing"; - - private static Fluid sAirFluid = null; - private static FluidStack sAirFluidStack = null; - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private static final int CASING_ID = TAE.getIndexFromPage(3, 11); - - public GregtechMetaTileEntity_LargeRocketEngine(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - this.fuelConsumption = 0; - this.fuelValue = 0; - this.fuelRemaining = 0; - this.boostEu = false; - setAir(); - } - - public GregtechMetaTileEntity_LargeRocketEngine(final String aName) { - super(aName); - this.fuelConsumption = 0; - this.fuelValue = 0; - this.fuelRemaining = 0; - this.boostEu = false; - setAir(); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Rocket Engine") - .addInfo("Generating Power from Rocket Fuels - Supports TecTech Multi-Amp Dynamos!") - .addInfo("Supply GT++ Rocket Fuels and 1000L of " + mLubricantName + " per hour") - .addInfo("Produces as much energy as you put fuel in, with optional boosting") - .addInfo("This multi doesn't accept fluids if not enabled - enable it first!") - .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") - .addInfo("Place 1-8 Air Intake Hatches on the sides to maintain Air input") - .addInfo("If it runs out of air, it will shut down and have to be manually restarted") - .addInfo("Supply 3L of " + mCoolantName + " per second, per 1000 EU/t to boost") - .addInfo("Takes 3x the amount of " + mLubricantName + " and maintains efficiency") - .addInfo("Fuel efficiency starts at ~160%, falls more slowly at higher EU/t if boosted") - .addInfo("If producing more than 30k EU/t, fuel efficiency will be lower:") - .addInfo("(These thresholds are 3x higher when boosted, boosted values displayed second)") - .addInfo("- 75% of max fuel efficiency at 53k or 159k EU/t output energy") - .addInfo("- 50% of max fuel efficiency at 69k or 207k EU/t output energy") - .addInfo("- 25% of max fuel efficiency at 98k or 294k EU/t output energy") - .addInfo("formula: x = input of energy (30000^(1/3)/ x^(1/3)) * (80000^(1/3)/ x^(1/3))") - .addSeparator() - .beginStructureBlock(3, 3, 10, false) - .addController("Front Center") - .addCasingInfoMin(mCasingName, 64, false) - .addCasingInfoMin(mGearboxName, 8, false) - .addStructureHint("Air Intake Hatch", 1) - .addInputBus("Side center line", 1) - .addInputHatch("Side center line", 1) - .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) - .addDynamoHatch("Top center line", 2) - .addMufflerHatch("Back Center", 3) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (this.STRUCTURE_DEFINITION == null) { - this.STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - this.mName, - transpose( - new String[][] { { "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC" }, - { "C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC" }, - { "CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC" }, })) - .addElement('C', ofBlock(getCasingBlock(), getCasingMeta())) - .addElement('I', ofBlock(getGearboxBlock(), getGearboxMeta())) - // side - .addElement( - 'S', - buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) - .atLeast(ImmutableMap.of(AirIntake, 8, InputBus, 1, InputHatch, 3, Maintenance, 1)) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - // top - .addElement( - 'T', - buildHatchAdder(GregtechMetaTileEntity_LargeRocketEngine.class) - .atLeast(ImmutableMap.of(AirIntake, 8, Dynamo.or(TTDynamo), 1, Maintenance, 1)) - .casingIndex(getCasingTextureIndex()) - .dot(2) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('M', Muffler.newAny(getCasingTextureIndex(), 3)) - .build(); - } - return this.STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(this.mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.mCasing = 0; - this.mTecTechDynamoHatches.clear(); - this.mAllDynamoHatches.clear(); - this.mAirIntakes.clear(); - return checkPiece(this.mName, 1, 1, 0) && this.mCasing >= 64 - 48 - && this.mAirIntakes.size() >= 1 - && checkHatch(); - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCALargeRocketEngineActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCALargeRocketEngine; - } - - @Override - protected int getCasingTextureId() { - return CASING_ID; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return this.getMaxEfficiency(aStack) > 0; - } - - public static void setAir() { - if (sAirFluidStack == null) { - sAirFluidStack = FluidUtils.getFluidStack("air", 1); - } - if (sAirFluid == null && sAirFluidStack != null) { - sAirFluid = sAirFluidStack.getFluid(); - } - } - - public int getAir() { - setAir(); - if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) { - return 0; - } else { - int totalAir = 0; - for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) { - if (u != null && u.mFluid != null) { - FluidStack f = u.mFluid; - if (f.isFluidEqual(sAirFluidStack)) { - totalAir += f.amount; - } - } - } - return totalAir; - } - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.rocketFuels; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - final ArrayList tFluids = this.getStoredFluids(); - this.clearRecipeMapForAllInputHatches(); - int aircount = getAir(); - int aAirToConsume = this.euProduction / 100; - if (aircount < aAirToConsume) { - stopMachine(ShutDownReasonRegistry.outOfFluid(new FluidStack(sAirFluid, aAirToConsume))); - return SimpleCheckRecipeResult.ofFailure("no_air"); - } else { - int aTotalAir = 0; - for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : this.mAirIntakes) { - if (aAirHatch.mFluid != null) { - aTotalAir += aAirHatch.getFluidAmount(); - } - } - if (aTotalAir >= aAirToConsume) { - int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); - if (aSplitAmount > 0) { - for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : mAirIntakes) { - boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; - if (!hasIntakeAir) { - this.freeFuelTicks = 0; - return SimpleCheckRecipeResult.ofFailure("no_air"); - } - } - } - } - } - // reset fuel ticks in case it does not reset when it stops - if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) this.freeFuelTicks = 0; - - if (tFluids.size() > 0 && getRecipeMap() != null) { - if (this.mRuntime % 72 == 0) { - if (!consumeCO2()) { - this.freeFuelTicks = 0; - return SimpleCheckRecipeResult.ofFailure("no_co2"); - } - } - if (this.freeFuelTicks == 0) { - this.boostEu = consumeLOH(); - } - for (final FluidStack hatchFluid1 : tFluids) { - if (hatchFluid1.isFluidEqual(sAirFluidStack)) { - continue; - } - if (this.freeFuelTicks == 0) { - for (final GT_Recipe aFuel : getRecipeMap().getAllRecipes()) { - final FluidStack tLiquid; - tLiquid = aFuel.mFluidInputs[0]; - if (hatchFluid1.isFluidEqual(tLiquid)) { - if (!consumeFuel(aFuel, hatchFluid1.amount)) { - continue; - } - this.fuelValue = aFuel.mSpecialValue * 3; - this.fuelRemaining = hatchFluid1.amount; - this.lEUt = ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5] << 1); - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = this.euProduction / 2000; - return CheckRecipeResultRegistry.GENERATING; - } - } - } else { - this.mEfficiencyIncrease = this.euProduction / 2000; - this.freeFuelTicks--; - this.lEUt = ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5] << 1); - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - return CheckRecipeResultRegistry.GENERATING; - } - } - } - this.lEUt = 0; - this.mEfficiency = 0; - this.freeFuelTicks = 0; - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - - /** - * Consumes Fuel if required. Free Fuel Ticks are handled here. - * - * @param aFuel - * @return - */ - public boolean consumeFuel(GT_Recipe aFuel, int amount) { - amount *= this.boostEu ? 0.3 : 0.9; - this.freeFuelTicks = 0; - int value = aFuel.mSpecialValue * 3; - int energy = value * amount; - if (amount < 5) return false; - FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); - if (!this.depleteInput(tLiquid)) { - return false; - } else { - this.fuelConsumption = this.boostEu ? amount * 3 : amount; - this.freeFuelTicks = 20; - setEUProduction(energy); - return true; - } - } - - public void setEUProduction(int energy) { - energy /= 20; - double energyEfficiency; - double tDivideEnergy = Math.cbrt(energy); - if (energy > 30000) { - // cbrt(30 000) / - energyEfficiency = (31.072325 / tDivideEnergy); - if (energy >= 80000) - // cbrt(80 000) / - energyEfficiency *= (43.0886938 / tDivideEnergy); - energyEfficiency *= energy; - } else { - energyEfficiency = energy; - } - this.euProduction = (int) (energyEfficiency); - if (this.boostEu) this.euProduction *= 3; - } - - public boolean consumeCO2() { - return this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) - || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1))); - } - - public boolean consumeLOH() { - int LOHamount = (3 * this.euProduction) / 1000; - return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); // (40 * ((long) - // euProduction / - // 10000)) - } - - @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) { - return true; - } - if (this.mAllDynamoHatches.size() > 0) { - return addEnergyOutputMultipleDynamos(aEU, true); - } - return false; - } - - @Override - public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { - int injected = 0; - long totalOutput = 0; - long aFirstVoltageFound = -1; - boolean aFoundMixedDynamos = false; - for (GT_MetaTileEntity_Hatch aDynamo : filterValidMTEs(this.mAllDynamoHatches)) { - long aVoltage = aDynamo.maxEUOutput(); - long aTotal = aDynamo.maxAmperesOut() * aVoltage; - // Check against voltage to check when hatch mixing - if (aFirstVoltageFound == -1) { - aFirstVoltageFound = aVoltage; - } else { - if (aFirstVoltageFound != aVoltage) { - aFoundMixedDynamos = true; - } - } - totalOutput += aTotal; - } - - if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { - explodeMultiblock(); - return false; - } - - long leftToInject; - long aVoltage; - int aAmpsToInject; - int aRemainder; - - for (GT_MetaTileEntity_Hatch aDynamo : filterValidMTEs(this.mAllDynamoHatches)) { - leftToInject = aEU - injected; - aVoltage = aDynamo.maxEUOutput(); - aAmpsToInject = (int) (leftToInject / aVoltage); - aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - long powerGain; - for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { - if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)) { - powerGain = aRemainder; - } else { - powerGain = aVoltage; - } - aDynamo.getBaseMetaTileEntity() - .increaseStoredEnergyUnits(powerGain, false); - injected += powerGain; - } - } - return injected > 0; - } - - public Block getCasingBlock() { - return ModBlocks.blockCasings4Misc; - } - - public byte getCasingMeta() { - return 11; - } - - public Block getGearboxBlock() { - return ModBlocks.blockCasings3Misc; - } - - public byte getGearboxMeta() { - return 1; - } - - public byte getCasingTextureIndex() { - return (byte) CASING_ID; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_LargeRocketEngine(this.mName); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("freeFuelTicks", this.freeFuelTicks); - aNBT.setInteger("euProduction", this.euProduction); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.freeFuelTicks = aNBT.getInteger("freeFuelTicks"); - this.euProduction = aNBT.getInteger("euProduction"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 1; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return this.euProduction; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 75 * (this.euProduction / 10000); - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return true; - } - - @Override - public String[] getExtraInfoData() { - return new String[] { "Rocket Engine", "Current Air: " + getAir(), - "Current Pollution: " + getPollutionPerTick(null), - "Time until next fuel consumption: " + this.freeFuelTicks, - "Current Output: " + this.lEUt * this.mEfficiency / 10000 + " EU/t", - "Fuel Consumption: " + (this.fuelConsumption) + "L/s", "Fuel Value: " + this.fuelValue + " EU/L", - "Fuel Remaining: " + this.fuelRemaining + " Litres", "Current Efficiency: " + this.mEfficiency / 100 + "%", - (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String getMachineType() { - return "Rocket Engine"; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java deleted file mode 100644 index 4403779d09..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java +++ /dev/null @@ -1,332 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.Muffler; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; -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_Muffler; -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_Recipe; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GregtechMetaTileEntity_LargeSemifluidGenerator extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - protected int fuelConsumption = 0; - protected int fuelValue = 0; - protected int fuelRemaining = 0; - protected boolean boostEu = false; - - public GregtechMetaTileEntity_LargeSemifluidGenerator(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_LargeSemifluidGenerator(String aName) { - super(aName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Large Semifluid Generator") - .addInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") - .addInfo("Supply Semifluid Fuels and 2000L of Lubricant per hour to run.") - .addInfo("Supply 80L of Oxygen per second to boost output (optional).") - .addInfo("Default: Produces 2048EU/t at 100% efficiency") - .addInfo("Boosted: Produces 6144EU/t at 150% efficiency") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 3, 4, false) - .addController("Front Center") - .addCasingInfoMin("Stable Titanium Machine Casing", 16, false) - .addCasingInfoMin("Steel Gear Box Machine Casing", 2, false) - .addCasingInfoMin("Engine Intake Machine Casing", 8, false) - .addInputHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .addDynamoHatch("Back Center", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; - } - - @Override - protected int getCasingTextureId() { - return 50; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - ArrayList tFluids = getStoredFluids(); - - // Check for lubricant and oxygen first, so we can compute costs ahead of time. - // This will allow us to check costs without needing to actually try to deplete fluids - // (wasting earlier fluids in the check if later fluids turn out to be insufficient). - FluidStack lubricant = Materials.Lubricant.getFluid(0L); - FluidStack oxygen = Materials.Oxygen.getGas(0L); - for (FluidStack hatchFluid : tFluids) { - if (hatchFluid.isFluidEqual(lubricant)) { - lubricant.amount = Math.max(lubricant.amount, hatchFluid.amount); - } else if (hatchFluid.isFluidEqual(oxygen)) { - oxygen.amount = Math.max(oxygen.amount, hatchFluid.amount); - } - } - boostEu = oxygen.amount >= 4L; - long lubricantCost = boostEu ? 2L : 1L; - if (lubricant.amount < lubricantCost) { - return SimpleCheckRecipeResult.ofFailure("no_lubricant"); - } - - for (FluidStack hatchFluid : tFluids) { // Loops through hatches - GT_Recipe aFuel = GTPPRecipeMaps.semiFluidFuels.getBackend() - .findFuel(hatchFluid); - if (aFuel == null) { - // Not a valid semi-fluid fuel. - continue; - } - - int newEUt = boostEu ? 4096 : 2048; - fuelConsumption = newEUt / aFuel.mSpecialValue; // Calc fuel consumption - FluidStack tLiquid = new FluidStack(hatchFluid.getFluid(), fuelConsumption); - if (depleteInput(tLiquid)) { // Deplete that amount - // We checked beforehand, so both of these depletions should succeed. - // But check the return values anyway just to be safe. - if (boostEu) { - if (!depleteInput(Materials.Oxygen.getGas(4L))) { - return SimpleCheckRecipeResult.ofFailure("no_oxygen"); - } - } - // Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) - if (mRuntime % 72 == 0 || mRuntime == 0) { - if (!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { - return SimpleCheckRecipeResult.ofFailure("no_lubricant"); - } - } - - fuelValue = aFuel.mSpecialValue; - fuelRemaining = hatchFluid.amount; // Record available fuel - this.lEUt = mEfficiency < 2000 ? 0 : newEUt; // Output 0 if startup is less than 20% - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 15; - return CheckRecipeResultRegistry.GENERATING; - } - } - - this.lEUt = 0; - this.mEfficiency = 0; - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "III", "CCC", "CCC", "CCC" }, { "I~I", "CGC", "CGC", "CMC" }, - { "III", "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_LargeSemifluidGenerator.class) - .atLeast(Muffler, InputHatch, Maintenance) - .casingIndex(getCasingTextureIndex()) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) - .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) - .addElement('I', ofBlock(getIntakeBlock(), getIntakeMeta())) - .addElement( - 'M', - Dynamo.or(TTDynamo) - .newAny(getCasingTextureIndex(), 2)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mDynamoHatches.clear(); - return checkPiece(mName, 1, 1, 0) && mCasing >= 16 && checkHatch(); - } - - public final boolean addLargeSemifluidGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public final boolean addLargeSemifluidGeneratorBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || this.isThisHatchMultiDynamo(aTileEntity)) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - public Block getCasingBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getCasingMeta() { - return 2; - } - - public Block getIntakeBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getIntakeMeta() { - return 13; - } - - public Block getGearboxBlock() { - return GregTech_API.sBlockCasings2; - } - - public byte getGearboxMeta() { - return 3; - } - - public byte getCasingTextureIndex() { - return 50; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_LargeSemifluidGenerator(this.mName); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return boostEu ? 15000 : 10000; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return true; - } - - @Override - public String[] getExtraInfoData() { - return new String[] { "Large Semifluid Generator", "Current Output: " + lEUt * mEfficiency / 10000 + " EU/t", - "Fuel Consumption: " + fuelConsumption + "L/t", "Fuel Value: " + fuelValue + " EU/L", - "Fuel Remaining: " + fuelRemaining + " Litres", "Current Efficiency: " + (mEfficiency / 100) + "%", - getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String getMachineType() { - return "Semifluid Generator"; - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java deleted file mode 100644 index ee989d22ca..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ /dev/null @@ -1,361 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.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.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -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 net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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 gregtech.api.enums.Materials; -import gregtech.api.enums.TAE; -import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.IIconContainer; -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.recipe.check.SimpleCheckRecipeResult; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.config.machinestats.ConfigMassFabricator; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; - -public class GregtechMetaTileEntity_MassFabricator - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3200; - - public static String mCasingName1 = "Matter Fabricator Casing"; - public static String mCasingName2 = "Containment Casing"; - public static String mCasingName3 = "Matter Generation Coil"; - - private int mMode = 0; - - private static final int MODE_SCRAP = 1; - private static final int MODE_UU = 0; - - public static boolean sRequiresUUA = false; - private static final FluidStack[] mUU = new FluidStack[2]; - private static final ItemStack[] mScrap = new ItemStack[2]; - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_MassFabricator(final String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Mass Fabricator / Recycler"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Matter Fabricator") - .addInfo("Speed: +0% | EU Usage: 80%") - .addInfo("Parallel: Scrap = 64 | UU = 8 * Tier") - .addInfo("Produces UU-A, UU-M & Scrap") - .addInfo("Change mode with screwdriver") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(5, 4, 5, true) - .addController("Front Center") - .addCasingInfoMin(mCasingName3, 9, false) - .addCasingInfoMin(mCasingName2, 24, false) - .addCasingInfoMin(mCasingName1, 36, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .addOutputHatch("Any Casing", 1) - .addEnergyHatch("Any Casing", 1) - .addMaintenanceHatch("Any Casing", 1) - .addMufflerHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Active_Animated; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_MatterFab_Animated; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(9); - } - - @Override - public void onConfigLoad() { - super.onConfigLoad(); - sDurationMultiplier = ConfigMassFabricator.durationMultiplier; - sUUAperUUM = ConfigMassFabricator.UUAPerUUM; - sUUASpeedBonus = ConfigMassFabricator.UUASpeedBonus; - sRequiresUUA = ConfigMassFabricator.requiresUUA; - } - - public static boolean sInit = false; - - public static void init() { - if (!sInit) { - if (mScrap[0] == null) { - mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); - } - if (mScrap[1] == null) { - mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); - } - if (mUU[0] == null) { - mUU[0] = Materials.UUAmplifier.getFluid(100); - } - if (mUU[1] == null) { - mUU[1] = Materials.UUMatter.getFluid(100); - } - sInit = true; - } - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, - { "CGGGC", "G---G", "G---G", "G---G", "CGGGC" }, - { "CGGGC", "G---G", "G---G", "G---G", "CGGGC" }, - { "CC~CC", "CHHHC", "CHHHC", "CHHHC", "CCCCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntity_MassFabricator.class) - .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) - .casingIndex(TAE.GTPP_INDEX(9)) - .dot(1) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 9)))) - .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 8)) - .addElement('G', ofBlock(ModBlocks.blockCasings3Misc, 15)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 2, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 2, 3, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 2, 3, 0) && mCasing >= 36 && checkHatch(); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiMassFabricator; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MassFabricator(this.mName); - } - - /** - * Special Recipe Handling - */ - @Override - public RecipeMap getRecipeMap() { - return this.mMode == MODE_SCRAP ? RecipeMaps.recyclerRecipes : GTPPRecipeMaps.multiblockMassFabricatorRecipes; - } - - @Nonnull - @Override - public Collection> getAvailableRecipeMaps() { - return Arrays.asList(RecipeMaps.recyclerRecipes, GTPPRecipeMaps.multiblockMassFabricatorRecipes); - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - public CheckRecipeResult process() { - init(); - return super.process(); - } - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (mMode == MODE_SCRAP) { - if (recipe.mOutputs == null) { - return SimpleCheckRecipeResult.ofSuccess("no_scrap"); - } - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @Nonnull - @Override - protected Stream findRecipeMatches(@Nullable RecipeMap map) { - if (mMode == MODE_SCRAP) { - if (inputItems != null) { - for (ItemStack item : inputItems) { - if (item == null || item.stackSize == 0) continue; - ItemStack aPotentialOutput = GT_ModHandler - .getRecyclerOutput(GT_Utility.copyAmount(1, item), 0); - GT_Recipe recipe = new GT_Recipe( - false, - new ItemStack[] { GT_Utility.copyAmount(1, item) }, - aPotentialOutput == null ? null : new ItemStack[] { aPotentialOutput }, - null, - new int[] { 2000 }, - null, - null, - 40, - (int) TierEU.RECIPE_LV, - 0); - return Stream.of(recipe); - } - } - return Stream.empty(); - } - return super.findRecipeMatches(map); - } - }.setEuModifier(0.8F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void setupProcessingLogic(ProcessingLogic logic) { - super.setupProcessingLogic(logic); - logic.enablePerfectOverclock(); - } - - @Override - public int getMaxParallelRecipes() { - return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - int aMode = this.mMode + 1; - if (aMode > 1) { - this.mMode = MODE_UU; - PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Matter/AmpliFabricator"); - } else if (aMode == 1) { - this.mMode = MODE_SCRAP; - PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); - } else { - this.mMode = MODE_SCRAP; - PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); - } - mLastRecipe = null; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mMode", mMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mMode = aNBT.getInteger("mMode"); - super.loadNBTData(aNBT); - } - - @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); - tag.setInteger("mode", mMode); - } - - @Override - public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { - super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); - currentTip.add( - StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " - + EnumChatFormatting.WHITE - + StatCollector.translateToLocal("GT5U.GTPP_MULTI_MASS_FABRICATOR.mode." + tag.getInteger("mode")) - + EnumChatFormatting.RESET); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java deleted file mode 100644 index 9f25f59f1f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java +++ /dev/null @@ -1,945 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.ExoticEnergy; -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_HatchElement.OutputHatch; -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_ParallelHelper.calculateChancedOutputMultiplier; -import static gregtech.api.util.GT_RecipeBuilder.BUCKETS; -import static gregtech.api.util.GT_RecipeBuilder.INGOTS; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -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.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -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.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -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 gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -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.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_Input; -import gregtech.api.objects.ItemData; -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.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; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("SpellCheckingInspection") -public class GregtechMetaTileEntity_QuantumForceTransformer - extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - protected int mCraftingTier = 0; - protected int mFocusingTier = 0; - protected int mMaxParallel = 0; - private boolean mFluidMode = false, doFermium = false, doNeptunium = false; - private static final Fluid mNeptunium = ELEMENT.getInstance().NEPTUNIUM.getPlasma(); - private static final Fluid mFermium = ELEMENT.getInstance().FERMIUM.getPlasma(); - private static final String MAIN_PIECE = "main"; - private GT_MetaTileEntity_Hatch_Input mNeptuniumHatch; - private GT_MetaTileEntity_Hatch_Input mFermiumHatch; - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition - .builder() - .addShape( - MAIN_PIECE, - new String[][] { // A - 142, B - 234, C - 177, D - 96, E - 224, H - 36, M - 21 - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " ", " ", " BAB ", " BBBBABBBB ", - " BAAAAAAAB ", " BABBABBAB ", " BA AB ", " A A ", " A A ", - " A A " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " ", " BAB ", " AAABBBAAA ", " BAAAAAAAAAB ", - " B B ", " A A ", " A A ", " ", " ", - " " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " BAB ", " AA AA ", " AA AA ", " BAA AAB ", - " B B ", " A A ", " A A ", " ", " ", - " " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " BAAAB ", " AA AA ", " AA AA ", "BAA AAB", - "B B", "A A", "A A", "A A", "A A", - "A A" }, - { " TTT ", " EEE ", " EEE ", " EEE ", " DDD ", - " EEE ", " DDD ", " EEE ", " EEE ", " EEE ", - " DDD ", " BAEEEAB ", " AA EEE AA ", " A EEE A ", "BA DDD AB", - "B EEE B", "B DDD B", " EEE ", " EEE ", " EEE ", - " Z~X " }, - { " TTTTT ", " ECCCE ", " ECCCE ", " ECCCE ", " D D ", - " ECCCE ", " D D ", " ECCCE ", " ECCCE ", " ECCCE ", - " D D ", " BAECCCEAB ", " A ECCCE A ", " A ECCCE A ", "BA D D AB", - "B ECCCE B", "B D D B", "B ECCCE B", " ECCCE ", " ECCCE ", - " HHHHH " }, - { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", - " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", - " D D ", " BAEC CEAB ", " B EC CE B ", "BB EC CE BB", "BA D D AB", - "A EC CE A", "A D D A", "A EC CE A", " EC CE ", " EC CE ", - " HHHHHHH " }, - { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", - " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", - " D D ", " AAEC CEAA ", " A EC CE A ", "AB EC CE BA", "AA D D AA", - "A EC CE A", "A D D A", " EC CE ", " EC CE ", " EC CE ", - " HHHHHHH " }, - { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", - " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", - " D D ", " BAEC CEAB ", " B EC CE B ", "BB EC CE BB", "BA D D AB", - "A EC CE A", "A D D A", "A EC CE A", " EC CE ", " EC CE ", - " HHHHHHH " }, - { " TTTTT ", " ECCCE ", " ECCCE ", " ECCCE ", " D D ", - " ECCCE ", " D D ", " ECCCE ", " ECCCE ", " ECCCE ", - " D D ", " BAECCCEAB ", " A ECCCE A ", " A ECCCE A ", "BA D D AB", - "B ECCCE B", "B D D B", "B ECCCE B", " ECCCE ", " ECCCE ", - " HHHHH " }, - { " TTT ", " EEE ", " EEE ", " EEE ", " DDD ", - " EEE ", " DDD ", " EEE ", " EEE ", " EEE ", - " DDD ", " BAEEEAB ", " AA EEE AA ", " A EEE A ", "BA DDD AB", - "B EEE B", "B DDD B", " EEE ", " EEE ", " EEE ", - " HHH " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " BAAAB ", " AA AA ", " AA AA ", "BAA AAB", - "B B", "A A", "A A", "A A", "A A", - "A A" }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " BAB ", " AA AA ", " AA AA ", " BAA AAB ", - " B B ", " A A ", " A A ", " ", " ", - " " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " ", " BAB ", " AAABBBAAA ", " BAAAAAAAAAB ", - " B B ", " A A ", " A A ", " ", " ", - " " }, - { " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", - " ", " ", " ", " BAB ", " BBBBABBBB ", - " BBBAAABBB ", " ABBAAABBA ", " A BA AB A ", " A A ", " A A ", - " A A " }, }) - .addElement( - 'A', - withChannel( - "manipulator", - StructureUtility.ofBlocksTiered( - craftingTierConverter(), - getAllCraftingTiers(), - 0, - GregtechMetaTileEntity_QuantumForceTransformer::setCraftingTier, - GregtechMetaTileEntity_QuantumForceTransformer::getCraftingTier))) - .addElement( - 'B', - withChannel( - "shielding", - StructureUtility.ofBlocksTiered( - focusingTierConverter(), - getAllFocusingTiers(), - 0, - GregtechMetaTileEntity_QuantumForceTransformer::setFocusingTier, - GregtechMetaTileEntity_QuantumForceTransformer::getFocusingTier))) - .addElement('C', ofBlock(ModBlocks.blockCasings4Misc, 4)) - .addElement('D', ofBlock(ModBlocks.blockCasings2Misc, 12)) - .addElement('E', lazy(t -> ofBlock(t.getCasingBlock1(), t.getCasingMeta1()))) - .addElement( - 'H', - buildHatchAdder(GregtechMetaTileEntity_QuantumForceTransformer.class) - .atLeast(InputBus, InputHatch, Maintenance, Energy.or(ExoticEnergy)) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(4) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) - .addElement( - 'T', - buildHatchAdder(GregtechMetaTileEntity_QuantumForceTransformer.class) - .atLeast(OutputBus, OutputHatch, Maintenance) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(5) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) - .addElement( - 'Z', - buildHatchAdder(GregtechMetaTileEntity_QuantumForceTransformer.class) - .hatchClass(GT_MetaTileEntity_Hatch_Input.class) - .adder(GregtechMetaTileEntity_QuantumForceTransformer::addNeptuniumHatch) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(5) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) - .addElement( - 'X', - buildHatchAdder(GregtechMetaTileEntity_QuantumForceTransformer.class) - .hatchClass(GT_MetaTileEntity_Hatch_Input.class) - .adder(GregtechMetaTileEntity_QuantumForceTransformer::addFermiumHatch) - .casingIndex(TAE.getIndexFromPage(0, 10)) - .dot(5) - .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) - .build(); - - public GregtechMetaTileEntity_QuantumForceTransformer(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_QuantumForceTransformer(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_QuantumForceTransformer(this.mName); - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Quantum Force Transformer") - .addInfo("Controller Block for the Quantum Force Transformer") - .addInfo("Allows Complex chemical lines to be performed instantly in one step") - .addInfo("Every recipe requires a catalyst, each catalyst adds 1 parallel and lasts forever") - .addInfo("Accepts TecTech Energy and Laser Hatches") - .addInfo("All inputs go on the bottom, all outputs go on the top") - .addInfo("Put a circuit in the controller to specify the focused output") - .addInfo("Check NEI to see the order of outputs, and which circuit number you need.") - .addInfo("If separate input busses are enabled put the circuit in the circuit slot of the bus") - .addInfo("Uses FocusTier*4*sqrt(parallels) Neptunium Plasma if focusing") - .addInfo("Can use FocusTier*4*sqrt(parallels) Fermium Plasma for additional chance output") - .addInfo("Use a screwdriver to enable Fluid mode") - .addInfo( - "Fluid mode turns all possible outputs into their fluid variant, those which can't are left as they were.") - .addInfo("This multi gets improved when all casings of some types are upgraded") - .addInfo("Casing functions:") - .addInfo("Pulse Manipulators: Recipe Tier Allowed (check NEI for the tier of each recipe)") - .addInfo("Shielding Cores: Focusing Tier (equal to or higher than recipe tier to allow focus)") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(15, 21, 15, true) - .addController("Bottom Center") - .addCasingInfoMin("Bulk Production Frame", 80, false) - .addCasingInfoMin("Quantum Force Conductor", 177, false) - .addCasingInfoMin("Force Field Glass", 224, false) - .addCasingInfoMin("Pulse Manipulators", 236, true) - .addCasingInfoMin("Shielding Cores", 142, true) - .addInputBus(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) - .addInputHatch(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) - .addOutputHatch(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) - .addOutputBus(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) - .addEnergyHatch(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) - .addStructureInfo( - EnumChatFormatting.WHITE + "Neptunium Plasma Hatch: " - + EnumChatFormatting.GREEN - + "Left" - + EnumChatFormatting.GRAY - + " side of Controller") - .addStructureInfo( - EnumChatFormatting.WHITE + "Fermium Plasma Hatch: " - + EnumChatFormatting.DARK_GREEN - + "Right" - + EnumChatFormatting.GRAY - + " side of Controller") - .toolTipFinisher( - GT_Values.AuthorBlueWeabo + EnumChatFormatting.RESET - + EnumChatFormatting.GREEN - + " + Steelux" - + EnumChatFormatting.RESET - + " - [GT++]"); - return tt; - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.mCasing = 0; - this.mCraftingTier = 0; - this.mFocusingTier = 0; - if (!checkPiece(MAIN_PIECE, 7, 20, 4)) { - return false; - } - - if (mOutputBusses.isEmpty() || mOutputHatches.isEmpty()) { - return false; - } - - // Maintenance hatch not required but left for compatibility. - // Don't allow more than 1, no free casing spam! - if (mMaintenanceHatches.size() > 1) { - return false; - } - - return checkExoticAndNormalEnergyHatches(); - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(MAIN_PIECE, stackSize, hintsOnly, 7, 20, 4); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(MAIN_PIECE, stackSize, 7, 20, 4, elementBudget, env, false, true); - } - - public static List> getAllCraftingTiers() { - return new ArrayList<>() { - - { - add(Pair.of(ModBlocks.blockCasings5Misc, 7)); - add(Pair.of(ModBlocks.blockCasings5Misc, 8)); - add(Pair.of(ModBlocks.blockCasings5Misc, 9)); - add(Pair.of(ModBlocks.blockCasings5Misc, 10)); - } - }; - } - - public static List> getAllFocusingTiers() { - return new ArrayList<>() { - - { - add(Pair.of(ModBlocks.blockCasings5Misc, 11)); - add(Pair.of(ModBlocks.blockCasings5Misc, 12)); - add(Pair.of(ModBlocks.blockCasings5Misc, 13)); - add(Pair.of(ModBlocks.blockCasings5Misc, 14)); - } - }; - } - - public static ITierConverter craftingTierConverter() { - return (block, meta) -> { - if (block == null) { - return -1; - } else if (block == ModBlocks.blockCasings5Misc) { // Resonance Chambers - switch (meta) { - case 7 -> { - return 1; - } - case 8 -> { - return 2; - } - case 9 -> { - return 3; - } - case 10 -> { - return 4; - } - } - } - return -1; - }; - } - - public static ITierConverter focusingTierConverter() { - return (block, meta) -> { - if (block == null) { - return -1; - } else if (block == ModBlocks.blockCasings5Misc) { // Generation Coils - switch (meta) { - case 11 -> { - return 1; - } - case 12 -> { - return 2; - } - case 13 -> { - return 3; - } - case 14 -> { - return 4; - } - } - } - return -1; - }; - } - - private void setCraftingTier(int tier) { - mCraftingTier = tier; - } - - private void setFocusingTier(int tier) { - mFocusingTier = tier; - } - - private int getCraftingTier() { - return mCraftingTier; - } - - private int getFocusingTier() { - return mFocusingTier; - } - - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAQFTActive; - } - - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAQFT; - } - - protected int getCasingTextureId() { - return TAE.getIndexFromPage(0, 10); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.quantumForceTransformerRecipes; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - private int[] chances; - private FluidStack[] fluidModeItems; - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (recipe.mSpecialValue > getCraftingTier()) { - return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue); - } - ItemStack catalyst = null; - for (ItemStack item : recipe.mInputs) { - if (ItemUtils.isCatalyst(item)) { - catalyst = item; - break; - } - } - - if (catalyst == null) { - return SimpleCheckRecipeResult.ofFailure("no_catalyst"); - } - - maxParallel = 0; - for (ItemStack item : inputItems) { - if (ItemUtils.isCatalyst(item) && item.isItemEqual(catalyst)) { - maxParallel += item.stackSize; - } - } - - mMaxParallel = maxParallel; - doFermium = false; - doNeptunium = false; - - if (recipe.mSpecialValue <= getFocusingTier()) { - if (drain(mFermiumHatch, new FluidStack(mFermium, 1), false)) { - doFermium = true; - } - if (drain(mNeptuniumHatch, new FluidStack(mNeptunium, 1), false)) { - doNeptunium = true; - } - } - - chances = getOutputChances(recipe, doNeptunium ? findProgrammedCircuitNumber() : -1); - - // Handle Fluid Mode. Add fluid that item can be turned into to fluidModeItems. - // null if Fluid Mode is disabled or item cannot be turned into fluid. - fluidModeItems = new FluidStack[recipe.mOutputs.length]; - if (mFluidMode) { - for (int i = 0; i < recipe.mOutputs.length; i++) { - ItemStack item = recipe.getOutput(i); - if (item == null) continue; - ItemData data = getAssociation(item); - Materials mat = data == null ? null : data.mMaterial.mMaterial; - if (mat != null) { - if (mat.mStandardMoltenFluid != null) { - fluidModeItems[i] = mat.getMolten(INGOTS); - } else if (mat.mFluid != null) { - fluidModeItems[i] = mat.getFluid(BUCKETS); - } - } - } - } - - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @NotNull - @Override - public GT_ParallelHelper createParallelHelper(@Nonnull GT_Recipe recipe) { - return super.createParallelHelper(recipe).setCustomItemOutputCalculation(parallel -> { - ArrayList items = new ArrayList<>(); - - for (int i = 0; i < recipe.mOutputs.length; i++) { - ItemStack item = recipe.getOutput(i); - if (item == null || fluidModeItems[i] != null) continue; - ItemStack itemToAdd = item.copy(); - double outputMultiplier = calculateChancedOutputMultiplier(chances[i], parallel); - long itemAmount = (long) (item.stackSize * outputMultiplier); - addItemsLong(items, itemToAdd, itemAmount); - } - - return items.toArray(new ItemStack[0]); - }) - .setCustomFluidOutputCalculation(parallel -> { - ArrayList fluids = new ArrayList<>(); - - if (mFluidMode) { - for (int i = 0; i < recipe.mOutputs.length; i++) { - FluidStack fluid = fluidModeItems[i]; - if (fluid == null) continue; - FluidStack fluidToAdd = fluid.copy(); - double outputMultiplier = calculateChancedOutputMultiplier(chances[i], parallel); - int itemAmount = recipe.mOutputs[i].stackSize; - long fluidAmount = (long) (fluidToAdd.amount * outputMultiplier * itemAmount); - 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(); - double outputMultiplier = calculateChancedOutputMultiplier( - chances[i + recipe.mOutputs.length], - parallel); - long fluidAmount = (long) (fluidToAdd.amount * outputMultiplier); - addFluidsLong(fluids, fluidToAdd, fluidAmount); - } - - return fluids.toArray(new FluidStack[0]); - }); - } - - private int findProgrammedCircuitNumber() { - if (isInputSeparationEnabled()) { - for (ItemStack stack : inputItems) { - if (GT_Utility.isAnyIntegratedCircuit(stack)) { - return stack.getItemDamage() - 1; - } - } - return -1; - } else { - final ItemStack controllerStack = getControllerSlot(); - return GT_Utility.isAnyIntegratedCircuit(controllerStack) ? controllerStack.getItemDamage() - 1 - : -1; - } - } - }; - } - - @Override - protected void setProcessingLogicPower(ProcessingLogic logic) { - logic.setAvailableVoltage(getAverageInputVoltage()); - logic.setAvailableAmperage(getMaxInputAmps()); - } - - private byte runningTick = 0; - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (!super.onRunningTick(aStack)) { - return false; - } - - if (runningTick % 20 == 0) { - int amount = (int) (getFocusingTier() * 4 - * Math.sqrt(Math.min(mMaxParallel, processingLogic.getCurrentParallels()))); - if (doFermium) { - FluidStack fermiumToConsume = new FluidStack(mFermium, amount); - if (!drain(mFermiumHatch, fermiumToConsume, true)) { - doFermium = false; - stopMachine(ShutDownReasonRegistry.outOfFluid(fermiumToConsume)); - return false; - } - } - - if (doNeptunium) { - FluidStack neptuniumToConsume = new FluidStack(mNeptunium, amount); - if (!drain(mNeptuniumHatch, neptuniumToConsume, true)) { - doNeptunium = false; - stopMachine(ShutDownReasonRegistry.outOfFluid(neptuniumToConsume)); - return false; - } - } - - runningTick = 1; - } else { - runningTick++; - } - - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - // TODO: Look for proper fix - // Updates every 30 sec - if (mUpdate <= -550) mUpdate = 50; - } - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public static int getBaseOutputChance(GT_Recipe tRecipe) { - int aOutputsAmount = tRecipe.mOutputs.length + tRecipe.mFluidOutputs.length; - return 10000 / aOutputsAmount; - } - - private int[] getOutputChances(GT_Recipe tRecipe, int aChanceIncreased) { - int difference = getFocusingTier() - tRecipe.mSpecialValue; - int aOutputsAmount = tRecipe.mOutputs.length + tRecipe.mFluidOutputs.length; - int aChancePerOutput = 10000 / aOutputsAmount; - int[] tChances = new int[aOutputsAmount]; - Arrays.fill(tChances, aChancePerOutput); - - switch (difference) { - case 0 -> { - for (int i = 0; i < tChances.length; i++) { - if (doNeptunium) { - if (i == aChanceIncreased) { - tChances[i] += aChancePerOutput / 2 * (aOutputsAmount - 1); - } else { - tChances[i] /= 2; - } - } - - if (doFermium) { - tChances[i] += (10000 - tChances[i]) / 4; - } - } - } - case 1 -> { - for (int i = 0; i < tChances.length; i++) { - if (doNeptunium) { - if (i == aChanceIncreased) { - tChances[i] += aChancePerOutput * 3 / 4 * (aOutputsAmount - 1); - } else { - tChances[i] /= 4; - } - } - - if (doFermium) { - tChances[i] += (10000 - tChances[i]) / 3; - } - } - } - case 2, 3 -> { - for (int i = 0; i < tChances.length; i++) { - if (doNeptunium) { - if (i == aChanceIncreased) { - tChances[i] = 10000; - } else { - tChances[i] = 0; - } - } - - if (doFermium) { - tChances[i] += (10000 - tChances[i]) / 2; - } - } - } - } - return tChances; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mFluidMode = !mFluidMode; - GT_Utility.sendChatToPlayer( - aPlayer, - StatCollector.translateToLocal("miscutils.machines.QFTFluidMode") + " " + mFluidMode); - } - - public boolean addNeptuniumHatch(IGregTechTileEntity aTileEntity, short aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - mNeptuniumHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; - return true; - } - return false; - } - - public boolean addFermiumHatch(IGregTechTileEntity aTileEntity, short aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - mFermiumHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; - return true; - } - return false; - } - - public Block getCasingBlock1() { - return ModBlocks.blockCasings5Misc; - } - - public byte getCasingMeta1() { - return 15; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mFluidMode", mFluidMode); - aNBT.setBoolean("doFermium", doFermium); - aNBT.setBoolean("doNeptunium", doNeptunium); - aNBT.setInteger("mMaxParallel", mMaxParallel); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - inputSeparation = aNBT.getBoolean("mSeparateInputBusses"); - } - if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { - batchMode = aNBT.getBoolean("mBatchMode"); - } - mFluidMode = aNBT.getBoolean("mFluidMode"); - doFermium = aNBT.getBoolean("doFermium"); - doNeptunium = aNBT.getBoolean("doNeptunium"); - mMaxParallel = aNBT.getInteger("mMaxParallel"); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, - int aColorIndex, boolean aActive, boolean aRedstone) { - if (side == facing) { - if (aActive) return new ITexture[] { getCasingTexture(), TextureFactory.builder() - .addIcon(getActiveOverlay()) - .extFacing() - .build() }; - return new ITexture[] { getCasingTexture(), TextureFactory.builder() - .addIcon(getInactiveOverlay()) - .extFacing() - .build() }; - } - return new ITexture[] { getCasingTexture() }; - } - - private ITexture getCasingTexture() { - return Textures.BlockIcons.getCasingTextureForId(getCasingTextureId()); - } - - @SideOnly(Side.CLIENT) - private void renderForceField(double x, double y, double z, int side, double minU, double maxU, double minV, - double maxV) { - // spotless:off - Tessellator tes = Tessellator.instance; - switch (side) { - case 0 -> { - tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); - tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); - tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); - tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); - tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); - tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); - } - case 1 -> { - tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); - tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); - } - case 2 -> { - tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); - tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); - tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); - tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); - tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); - tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); - } - case 3 -> { - tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); - tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); - } - case 4 -> { - tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); - tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); - tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); - tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); - } - case 5 -> { - tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); - tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); - } - case 6 -> { - tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); - tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); - tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); - tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); - } - case 7 -> { - tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); - tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); - } - } - } - - @SideOnly(Side.CLIENT) - @Override - public boolean renderInWorld(IBlockAccess aWorld, int x, int y, int z, Block block, RenderBlocks renderer) { - Tessellator tes = Tessellator.instance; - IIcon forceField = TexturesGtBlock.ForceField.getIcon(); - if (getBaseMetaTileEntity().isActive()) { - double minU = forceField.getMinU(); - double maxU = forceField.getMaxU(); - double minV = forceField.getMinV(); - double maxV = forceField.getMaxV(); - double xBaseOffset = 3 * getExtendedFacing().getRelativeBackInWorld().offsetX; - double zBaseOffset = 3 * getExtendedFacing().getRelativeBackInWorld().offsetZ; - tes.setColorOpaque_F(1f, 1f, 1f); - tes.setBrightness(15728880); - //Center O: 0, 0 1 ------- 8 - //Corner 1: 7, -2 / \ - //Corner 2: 3, -6 2 / \ 7 - //Corner 3: -2, -6 | | - //Corner 4: -6, -2 | O | - //Corner 5: -6, 3 | | - //Corner 6: -2, 7 3 \ / 6 - //Corner 7: 3, 7 \ / - //Corner 8: 7, 3 4 ------- 5 - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 0, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 1, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 2, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 3, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 4, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 5, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 6, minU, maxU, minV, maxV); - renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 7, minU, maxU, minV, maxV); - } - // Needs to be false to render the controller - return false; - //spotless:on - } - - @Override - public boolean supportsInputSeparation() { - return true; - } - - @Override - public boolean supportsBatchMode() { - return true; - } - - @Override - public boolean getDefaultHasMaintenanceChecks() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java deleted file mode 100644 index 8a6564858e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ /dev/null @@ -1,220 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Energy; -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.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; - -import net.minecraft.item.ItemStack; - -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 gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; -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_Muffler; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_Refinery(final String aName) { - super(aName); - } - - @Override - public String getMachineType() { - return "Fuel Refinery"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Fission Fuel Processing Unit") - .addInfo("Refines fluorides and Uranium into nuclear fuel for the LFTR") - .addInfo("LFTR Fuel 2 and Fuel 3 have alternative, much more efficient recipes") - .addInfo("However, they require fission breeding outputs from the LFTR itself") - .addInfo("Only one Energy Hatch is allowed per Processing Unit") - .addInfo("All recipe times in this multi are very long, watch out!") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(3, 9, 3, false) - .addController("Bottom Center") - .addCasingInfoMin("Hastelloy-X Structural Block", 7, false) - .addCasingInfoMin("Incoloy-DS Fluid Containment Block", 5, false) - .addCasingInfoMin("Zeron-100 Reactor Shielding", 4, false) - .addCasingInfoMin("Hastelloy-N Sealant Blocks", 17, false) - .addInputHatch("Base platform", 1) - .addOutputHatch("Base platform", 1) - .addMufflerHatch("Base platform", 1) - .addMaintenanceHatch("Base platform", 1) - .addEnergyHatch("Base platform", 1) - .addStructureInfo("Muffler's Tier must be IV+") - .addStructureInfo("2-4x Input Hatches, 1-2x Output Hatches") - .addStructureInfo("1x Muffler, 1x Maintenance Hatch, 1x Energy Hatch") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; - } - - @Override - protected int getCasingTextureId() { - return TAE.GTPP_INDEX(18); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.fissionFuelProcessingRecipes; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic(); - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler - && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 5) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { { " ", " N ", " " }, { " N ", "NIN", " N " }, { " N ", "NIN", " N " }, - { " N ", "NIN", " N " }, { " Z ", "ZIZ", " Z " }, { " N ", "NIN", " N " }, - { "XXX", "XXX", "XXX" }, { "X~X", "XXX", "XXX" }, })) - .addElement( - 'X', - ofChain( - buildHatchAdder(GregtechMetaTileEntity_Refinery.class) - .atLeast(Energy, Maintenance, OutputHatch, OutputBus, InputHatch) - .casingIndex(TAE.GTPP_INDEX(18)) - .dot(1) - .build(), - buildHatchAdder(GregtechMetaTileEntity_Refinery.class).atLeast(Muffler) - .adder(GregtechMetaTileEntity_Refinery::addMufflerToMachineList) - .hatchItemFilterAnd(t -> filterByMTETier(6, Integer.MAX_VALUE)) - .casingIndex(TAE.GTPP_INDEX(18)) - .dot(1) - .build(), - onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 2)))) - .addElement('I', ofBlock(ModBlocks.blockCasings2Misc, 3)) - .addElement('N', ofBlock(ModBlocks.blockCasings2Misc, 1)) - .addElement('Z', ofBlock(ModBlocks.blockCasingsMisc, 13)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 7, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 7, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { - if (this.mInputHatches.size() >= 2 && this.mInputHatches.size() <= 4 - && this.mOutputHatches.size() >= 1 - && this.mOutputHatches.size() <= 2 - && this.mMufflerHatches.size() == 1 - && this.mMaintenanceHatches.size() == 1 - && this.mEnergyHatches.size() == 1) { - this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); - return true; - } - } - return false; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiRefinery; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_Refinery(this.mName); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java deleted file mode 100644 index 0f3d201cb5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java +++ /dev/null @@ -1,675 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.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_Utility; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.tileentities.misc.TileEntitySolarHeater; - -public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - // 862 - private static final int mCasingTextureID = TAE.getIndexFromPage(3, 9); - private int mHeatLevel = 0; - private int mCasing1; - private int mCasing2; - private int mCasing3; - private int mCasing4; - - public ArrayList mSolarHeaters = new ArrayList<>(); - - public GregtechMetaTileEntity_SolarTower(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_SolarTower(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_SolarTower(this.mName); - } - - @Override - public String getMachineType() { - return "Solar Tower"; - } - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Contributing Green Energy towards the future") - .addInfo("Surround with rings of Solar Reflectors") - .addInfo("The Reflectors increase the internal heat value of the Tower (see below for formula)") - .addInfo("Each Reflector ring increases tier, the first ring is required for the Tower to work") - .addInfo("Input: " + MISC_MATERIALS.SOLAR_SALT_COLD.getLocalizedName()) - .addInfo("Output: " + MISC_MATERIALS.SOLAR_SALT_HOT.getLocalizedName()) - .addInfo("Every cycle (10 seconds), heat increases and all the Cold Solar Salt is heated") - .addInfo("Converting Cold to Hot Solar Salt reduces heat, equal to the amount converted") - .addInfo("This conversion only happens if heat >= 30000 and controller efficiency = 100%") - .addInfo("If there's more Cold Salt than heat, all the heat is used up and returns to 0") - .addInfo("The heat increase is most efficient at exactly half of maximum heat") - .addInfo("Minimum efficiency at 0 or 100000 heat, maximum efficiency at 50000") - .addInfo("Heat Efficiency formula: ( 7000 - [|currentHeat - 50000| ^ 0.8]) / 7000") - .addInfo("Heat gain per cycle: numberHeaters * heatEfficiency * (10 + bonus)") - .addInfo("Bonus: 1 ring = +1, 2 rings = +2, 3 rings = +4, 4 rings = +8, 5 rings = +16") - .addInfo("Total number of reflectors based on how many rings are built:") - .addInfo("1 ring = 36, 2 rings = 88, 3 rings = 156, 4 rings = 240, 5 rings = 340") - .addSeparator() - .beginVariableStructureBlock(15, 31, 28, 28, 15, 31, false) - .addController("Top Middle") - .addCasingInfoMin("Structural Solar Casing", 229, false) - .addCasingInfoMin("Thermally Insulated Casing", 60, false) - .addCasingInfoMin("Salt Containment Casing", 66, false) - .addCasingInfoMin("Thermal Containment Casing", 60, false) - .addInputHatch("Any 2 dot hint(min 1)", 2) - .addOutputHatch("Any 2 dot hint(min 1)", 2) - .addMaintenanceHatch("Any 2 dot hint", 2) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private static final String STRUCTURE_PIECE_BASE = "base"; - private static final String STRUCTURE_PIECE_TOWER = "tower"; - private static final String STRUCTURE_PIECE_TOP = "top"; - - private static final String[] STRUCTURE_PIECE_SOLAR_HEATER_RING = { "ring1", "ring2", "ring3", "ring4", "ring5" }; - private static final String SOLAR_HEATER_RING_1 = STRUCTURE_PIECE_SOLAR_HEATER_RING[0]; - private static final String SOLAR_HEATER_RING_2 = STRUCTURE_PIECE_SOLAR_HEATER_RING[1]; - private static final String SOLAR_HEATER_RING_3 = STRUCTURE_PIECE_SOLAR_HEATER_RING[2]; - private static final String SOLAR_HEATER_RING_4 = STRUCTURE_PIECE_SOLAR_HEATER_RING[3]; - private static final String SOLAR_HEATER_RING_5 = STRUCTURE_PIECE_SOLAR_HEATER_RING[4]; - - private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { - - @Override - protected IStructureDefinition computeValue(Class type) { - return StructureDefinition.builder() - - // s = salt - // c = thermal containment - // i = thermal insulated - // t = solar structural - // h = hatch - // g = solar heater - - .addShape( - STRUCTURE_PIECE_TOP, - (new String[][] { { " ", " ", " ~ ", " ", " " }, - { " ", " s ", " sss ", " s ", " " }, - { " c ", " ccc ", "ccscc", " ccc ", " c " }, - { " c ", " ccc ", "ccscc", " ccc ", " c " }, - { " c ", " ccc ", "ccscc", " ccc ", " c " }, - { " c ", " ccc ", "ccscc", " ccc ", " c " }, - { " c ", " ccc ", "ccscc", " ccc ", " c " }, })) - .addShape( - STRUCTURE_PIECE_TOWER, - (new String[][] { { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, - { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, - { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, - { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, - { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, })) - .addShape( - STRUCTURE_PIECE_BASE, - (new String[][] { - { " ", " ", " t ", " ttt ", " ttstt ", " ttssstt ", - " ttstt ", " ttt ", " t ", " ", " " }, - { " ", " ", " t ", " ttt ", " tssst ", " ttssstt ", - " tssst ", " ttt ", " t ", " ", " " }, - { " ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", - " ttssstt ", " ttttt ", " ttt ", " t ", " " }, - { " ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", - " ttssstt ", " ttttt ", " ttt ", " t ", " " }, - { " hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "htttsssttth", "htttsssttth", - "htttsssttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh " }, - { " hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "httttttttth", "httttttttth", - "httttttttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh " }, })) - .addShape( - SOLAR_HEATER_RING_1, - (new String[][] { { " ggggg ", " g g ", " g g ", " g g ", - " g g ", "g g", "g g", "g g", "g g", - "g g", " g g ", " g g ", " g g ", " g g ", - " ggggg ", } })) - .addShape( - SOLAR_HEATER_RING_2, - (new String[][] { - { " ggggggggg ", " g g ", " g g ", " g g ", - " g g ", "g g", "g g", "g g", - "g g", "g g", "g g", "g g", - "g g", "g g", " g g ", " g g ", - " g g ", " g g ", " ggggggggg ", } })) - .addShape( - SOLAR_HEATER_RING_3, - (new String[][] { { " ggggggggggggg ", " g g ", " g g ", - " g g ", " g g ", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - " g g ", " g g ", " g g ", - " g g ", " ggggggggggggg ", } })) - .addShape( - SOLAR_HEATER_RING_4, - (new String[][] { { " ggggggggggggggggg ", " g g ", - " g g ", " g g ", " g g ", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", "g g", - "g g", "g g", " g g ", - " g g ", " g g ", " g g ", - " ggggggggggggggggg ", } })) - .addShape( - SOLAR_HEATER_RING_5, - (new String[][] { { " ggggggggggggggggggggg ", " g g ", - " g g ", " g g ", - " g g ", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - "g g", "g g", - " g g ", " g g ", - " g g ", " g g ", - " ggggggggggggggggggggg ", } })) - .addElement( - 'g', - lazy( - t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) - .hatchClass(TileEntitySolarHeater.class) - .adder(GregtechMetaTileEntity_SolarTower::addSolarHeater) - // Use a positive casing index to make adder builder happy - .casingIndex(1) - .dot(1) - .continueIfSuccess() - .build())) - .addElement( - 't', - lazy(t -> onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) - .addElement( - 'i', - lazy(t -> onElementPass(x -> ++x.mCasing2, ofBlock(t.getCasingBlock(), t.getCasingMeta2())))) - .addElement( - 's', - lazy(t -> onElementPass(x -> ++x.mCasing3, ofBlock(t.getCasingBlock(), t.getCasingMeta3())))) - .addElement( - 'c', - lazy(t -> onElementPass(x -> ++x.mCasing4, ofBlock(t.getCasingBlock2(), t.getCasingMeta4())))) - .addElement( - 'h', - lazy( - t -> buildHatchAdder(GregtechMetaTileEntity_SolarTower.class) - .atLeast(InputHatch, OutputHatch, Maintenance) - .casingIndex(t.getCasingTextureIndex()) - .dot(2) - .buildAndChain( - onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta()))))) - .build(); - } - }; - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - resetSolarHeaters(); - this.mMaintenanceHatches.clear(); - this.mInputHatches.clear(); - this.mOutputHatches.clear(); - mCasing1 = 0; - mCasing2 = 0; - mCasing3 = 0; - mCasing4 = 0; - - boolean aStructureTop = checkPiece(STRUCTURE_PIECE_TOP, 2, 2, 0); - log("Top Check: " + aStructureTop); - boolean aStructureTower = checkPiece(STRUCTURE_PIECE_TOWER, 1, 1, -7); - log("Tower Check: " + aStructureTower); - boolean aStructureBase = checkPiece(STRUCTURE_PIECE_BASE, 5, 5, -22); - log("Base Check: " + aStructureBase); - boolean aCasingCount1 = mCasing1 >= 229; - boolean aCasingCount2 = mCasing2 == 60; - boolean aCasingCount3 = mCasing3 == 66; - boolean aCasingCount4 = mCasing4 == 60; - boolean aAllStructure = aStructureTop && aStructureTower && aStructureBase; - boolean aAllCasings = aCasingCount1 && aCasingCount2 && aCasingCount3 && aCasingCount4; - if (!aAllCasings || !aAllStructure - || mMaintenanceHatches.size() != 1 - || mInputHatches.size() < 1 - || mOutputHatches.size() < 1) { - log( - "Bad Hatches - Solar Heaters: " + mSolarHeaters.size() - + ", Maint: " - + mMaintenanceHatches.size() - + ", Input Hatches: " - + mInputHatches.size() - + ", Output Hatches: " - + mOutputHatches.size() - + ", Top: " - + aStructureTop - + ", Tower: " - + aStructureTower - + ", Base: " - + aStructureBase - + ", Casing Count: " - + aCasingCount1 - + " | Found: " - + mCasing1 - + ", Casing Count: " - + aCasingCount2 - + " | Found: " - + mCasing2 - + ", Casing Count: " - + aCasingCount3 - + " | Found: " - + mCasing3 - + ", Casing Count: " - + aCasingCount4 - + " | Found: " - + mCasing4); - return false; - } - log( - "Built " + this.getLocalName() - + " with " - + mCasing1 - + " Structural Solar casings, " - + mCasing2 - + " Thermally Insulated casings, " - + mCasing3 - + " Salt Containment casings, " - + mCasing4 - + " Thermal Containment casings."); - return aAllCasings && aAllStructure; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // Tower - buildPiece(STRUCTURE_PIECE_TOP, stackSize, hintsOnly, 2, 2, 0); - buildPiece(STRUCTURE_PIECE_TOWER, stackSize, hintsOnly, 1, 1, -7); - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 5, 5, -22); - - // Solar Heaters - if (stackSize.stackSize >= 1) { - buildPiece(SOLAR_HEATER_RING_1, stackSize, hintsOnly, 7, 7, -27); - if (stackSize.stackSize >= 2) { - buildPiece(SOLAR_HEATER_RING_2, stackSize, hintsOnly, 9, 9, -27); - if (stackSize.stackSize >= 3) { - buildPiece(SOLAR_HEATER_RING_3, stackSize, hintsOnly, 11, 11, -27); - if (stackSize.stackSize >= 4) { - buildPiece(SOLAR_HEATER_RING_4, stackSize, hintsOnly, 13, 13, -27); - if (stackSize.stackSize >= 5) { - buildPiece(SOLAR_HEATER_RING_5, stackSize, hintsOnly, 15, 15, -27); - } - } - } - } - } - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - int built; - int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); - // Tower - built = survivialBuildPiece(STRUCTURE_PIECE_TOP, stackSize, 2, 2, 0, realBudget, env, false, true); - if (built >= 0) return built; - built = survivialBuildPiece(STRUCTURE_PIECE_TOWER, stackSize, 1, 1, -7, realBudget, env, false, true); - if (built >= 0) return built; - built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 5, 5, -22, realBudget, env, false, true); - if (built >= 0) return built; - - // Solar Heaters - if (stackSize.stackSize < 1) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_1, stackSize, 7, 7, -27, realBudget, env, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 2) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_2, stackSize, 9, 9, -27, realBudget, env, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 3) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_3, stackSize, 11, 11, -27, realBudget, env, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 4) return -1; - built = survivialBuildPiece(SOLAR_HEATER_RING_4, stackSize, 13, 13, -27, realBudget, env, false, true); - if (built >= 0) return built; - if (stackSize.stackSize < 5) return -1; - return survivialBuildPiece(SOLAR_HEATER_RING_5, stackSize, 15, 15, -27, realBudget, env, false, true); - } - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION.get(getClass()); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) { - if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCDSolarTowerActive) - .extFacing() - .build() }; - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCDSolarTower) - .extFacing() - .build() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; - } - - @Override - public RecipeMap getRecipeMap() { - // Only for visual - return GTPPRecipeMaps.solarTowerRecipes; - } - - private int getHeaterTier() { - int aSolarHeaterCounter = this.mSolarHeaters.size(); - if (aSolarHeaterCounter > 0) { - if (aSolarHeaterCounter == 36) { - return 1; - } else if (aSolarHeaterCounter == 88) { - return 2; - } else if (aSolarHeaterCounter == 156) { - return 4; - } else if (aSolarHeaterCounter == 240) { - return 8; - } else if (aSolarHeaterCounter == 340) { - return 16; - } - } - return 0; - } - - private int getHeaterCountForTier(int aTier) { - return switch (aTier) { - case 1 -> 36; - case 2 -> 88; - case 4 -> 156; - case 8 -> 240; - case 16 -> 340; - default -> 0; - }; - } - - public boolean getConnectedSolarReflectors() { - - resetSolarHeaters(); - int aRing = 1; - - if (this.mSolarHeaters.size() < 36) { - // 15x15 - boolean aRing1 = checkPiece(SOLAR_HEATER_RING_1, 7, 7, -27); - if (aRing1) { - // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 88) { - // 17x17 - boolean aRing2 = checkPiece(SOLAR_HEATER_RING_2, 9, 9, -27); - if (aRing2) { - // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 156) { - // 19x19 - boolean aRing3 = checkPiece(SOLAR_HEATER_RING_3, 11, 11, -27); - if (aRing3) { - // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 240) { - // 21x21 - boolean aRing4 = checkPiece(SOLAR_HEATER_RING_4, 13, 13, -27); - if (aRing4) { - // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - if (this.mSolarHeaters.size() < 340) { - // 23x23 - boolean aRing5 = checkPiece(SOLAR_HEATER_RING_5, 15, 15, -27); - if (aRing5) { - // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); - } - } - return mSolarHeaters.size() > 0; - } - - private boolean addSolarHeater(IGregTechTileEntity aTileEntity, int a) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof TileEntitySolarHeater mTile) { - if (!mTile.hasSolarTower() && mTile.canSeeSky()) { - // Logger.INFO("Found Solar Reflector, Injecting Data."); - mTile.setSolarTower(this); - return this.mSolarHeaters.add(mTile); - } - } - } - return false; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d == ForgeDirection.UP; - } - - private Fluid mColdSalt = null; - private Fluid mHotSalt = null; - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - this.mEfficiencyIncrease = 100; - this.mMaxProgresstime = 200; - - if (this.mSolarHeaters.isEmpty() || this.mSolarHeaters.size() < 340 - || this.getTotalRuntimeInTicks() % 200 == 0) { - getConnectedSolarReflectors(); - } - - int aTier = getHeaterTier(); - int aHeaters = getHeaterCountForTier(aTier); - - // Original formula was (-Math.pow(this.mHeatLevel - 50000, 0.8) + 7000) / 7000 - // However, negative numbers to the power of a non-integer result in NaN, by default - // Max efficiency is 1, at mHeatLevel = 50000, and it lowers at the same rate if going above or below this heat - // Min efficiency is 0.179, at mHeatLevel = 0 or 100000 - double aEfficiency = (-Math.pow(Math.abs(this.mHeatLevel - 50000), 0.8) + 7000) / 7000; - - World w = this.getBaseMetaTileEntity() - .getWorld(); - - // Manage Heat every 10s - // Add Heat First, if sources available and it's daytime, heat gain is halved if raining - if (w != null) { - if (aHeaters > 0 && w.isDaytime()) { - if (w.isRaining() && this.getBaseMetaTileEntity() - .getBiome().rainfall > 0.0F) { - this.mHeatLevel += GT_Utility.safeInt((long) ((aHeaters / 2) * aEfficiency * (10 + aTier))); - } else { - this.mHeatLevel += GT_Utility.safeInt((long) (aHeaters * aEfficiency * (10 + aTier))); - } - } - - // Remove Heat, based on time of day - if (mHeatLevel > 0) { - if (mHeatLevel > 100000) { - this.mHeatLevel = 100000; - } else { - this.mHeatLevel -= 10; - } - } - } - - if (this.mEfficiency == this.getMaxEfficiency(null) && this.mHeatLevel >= 30000) { - if (mColdSalt == null) { - mColdSalt = MISC_MATERIALS.SOLAR_SALT_COLD.getFluid(); - } - if (mHotSalt == null) { - mHotSalt = MISC_MATERIALS.SOLAR_SALT_HOT.getFluid(); - } - ArrayList aFluids = this.getStoredFluids(); - for (FluidStack aFluid : aFluids) { - if (aFluid.getFluid() - .equals(mColdSalt)) { - int aFluidAmount = Math.min(aFluid.amount, this.mHeatLevel); - - this.mHeatLevel -= aFluidAmount; - this.depleteInput(FluidUtils.getFluidStack(mColdSalt, aFluidAmount)); - this.addOutput(FluidUtils.getFluidStack(mHotSalt, aFluidAmount)); - this.mHeatLevel = Math.max(this.mHeatLevel, 0); - - break; - } - } - } - - return CheckRecipeResultRegistry.GENERATING; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - public Block getCasingBlock2() { - return ModBlocks.blockCasings2Misc; - } - - public byte getCasingMeta() { - return 6; - } - - public byte getCasingMeta2() { - return 8; - } - - public byte getCasingMeta3() { - return 7; - } - - public byte getCasingMeta4() { - return 11; - } - - public byte getCasingTextureIndex() { - return (byte) mCasingTextureID; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mHeatLevel", mHeatLevel); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mHeatLevel = aNBT.getInteger("mHeatLevel"); - } - - @Override - public void onRemoval() { - resetSolarHeaters(); - super.onRemoval(); - } - - private void resetSolarHeaters() { - for (TileEntitySolarHeater aTile : this.mSolarHeaters) { - aTile.clearSolarTower(); - } - this.mSolarHeaters.clear(); - } - - @Override - public String[] getExtraInfoData() { - return new String[] { "Internal Heat Level: " + this.mHeatLevel, - "Connected Solar Reflectors: " + this.mSolarHeaters.size() }; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAlloyBlastSmelter.java new file mode 100644 index 0000000000..20c14d1ed2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAlloyBlastSmelter.java @@ -0,0 +1,232 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +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.minecraftforge.common.util.ForgeDirection; + +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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEAlloyBlastSmelter extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mMode = 0; + private boolean isUsingControllerCircuit = false; + private static Item circuit; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEAlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAlloyBlastSmelter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEAlloyBlastSmelter(this.mName); + } + + @Override + public String getMachineType() { + return "Fluid Alloy Cooker"; + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("isBussesSeparate")) { + inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Alloy Blast Smelter") + .addInfo("Allows Complex GT++ alloys to be created") + .addInfo("Accepts only one Energy Hatch") + .addInfo("Circuit for recipe goes in the Input Bus or GUI slot") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfoMin("Blast Smelter Casings", 5, false) + .addCasingInfoMin("Blast Smelter Heat Containment Coils", 16, false) + .addInputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, + { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEAlloyBlastSmelter.class) + .atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(15)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 15)))) + .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 14)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 3, 0) && mCasing >= 5 && mEnergyHatches.size() == 1 && checkHatch(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_INDUCTION_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDAlloyBlastSmelterActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDAlloyBlastSmelter; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(15); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.alloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + if (this.getBaseMetaTileEntity() + .isServerSide()) { + // Get Controller Circuit + if (circuit == null) { + circuit = GTUtility.getIntegratedCircuit(0) + .getItem(); + } + if (aStack != null && aStack.getItem() == circuit) { + this.mMode = aStack.getItemDamage(); + return this.isUsingControllerCircuit = true; + } else { + if (aStack == null) { + this.isUsingControllerCircuit = false; + return true; // Allowed empty + } + Logger.WARNING("Not circuit in GUI inputs."); + return this.isUsingControllerCircuit = false; + } + } + Logger.WARNING("No Circuit, clientside."); + return this.isUsingControllerCircuit = false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiABS; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAutoCrafter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAutoCrafter.java new file mode 100644 index 0000000000..41b9abf12e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEAutoCrafter.java @@ -0,0 +1,195 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTEAutoCrafter extends GTPPMultiBlockBase implements ISurvivalConstructable { + + protected GTRecipe lastRecipeToBuffer; + private int casing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEAutoCrafter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAutoCrafter(String mName) { + super(mName); + } + + @Override + public String getMachineType() { + return "Assembler"; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity tileEntity) { + return new MTEAutoCrafter(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Highly Advanced Assembling Machine") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoRange("Bulk Production Frame", 10, 25, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 10); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEAutoCrafter.class) + .atLeast(InputBus, OutputBus, InputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.casing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack itemStack, boolean hintsOnly) { + buildPiece(mName, itemStack, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, itemStack, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity baseMetaTileEntity, ItemStack itemStack) { + casing = 0; + return checkPiece(mName, 1, 1, 0) && casing >= 10 && checkHatch(); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.assemblerRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + public int getMaxParallelRecipes() { + return 2 * (Math.max(1, GTUtility.getTier(getMaxInputVoltage()))); + } + + @Override + public String[] getExtraInfoData() { + final String running = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); + final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" + : "Needs Maintenance"); + String tSpecialText; + + if (lastRecipeToBuffer != null && lastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { + tSpecialText = "Currently processing: " + lastRecipeToBuffer.mOutputs[0].getDisplayName(); + } else { + tSpecialText = "Currently processing: Nothing"; + } + + return new String[] { "Large Scale Auto-Assembler v1.01c", running, maintenance, tSpecialText }; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java new file mode 100644 index 0000000000..051daee9a3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java @@ -0,0 +1,337 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.SoundResource; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; +import gregtech.api.objects.GTItemStack; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTECyclotron extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTECyclotron(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + } + + public MTECyclotron(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Particle Accelerator"; + } + + public int tier() { + return 5; + } + + @Override + public long maxEUStore() { + return 1800000000L; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTECyclotron(this.mName); + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aStack) { + return side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { + { " ", " hhh ", " hh hh ", " h h ", + " h h ", " h h ", " h h ", " h h ", + " h h ", " h h ", " h h ", " h h ", + " hh hh ", " hhh ", " ", }, + { " hhh ", " hhccchh ", " hcchhhcch ", " hchh hhch ", + " hch hch ", " hch hch ", "hch hch", "hch hch", + "hch hch", " hch hch ", " hch hch ", " hchh hhch ", + " hcch~hcch ", " hhccchh ", " hhh ", }, + { " ", " hhh ", " hh hh ", " h h ", + " h h ", " h h ", " h h ", " h h ", + " h h ", " h h ", " h h ", " h h ", + " hh hh ", " hhh ", " ", } })) + .addElement( + 'h', + buildHatchAdder(MTECyclotron.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch, OutputHatch) + .casingIndex(44) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('c', ofBlock(getCyclotronCoil(), getCyclotronCoilMeta())) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 7, 1, 12); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 7, 1, 12, elementBudget, env, false, true); + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_FUSION_LOOP.resourceLocation; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 7, 1, 12) && mCasing >= 40 && checkHatch(); + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public int getCasingMeta() { + return 10; + } + + public Block getCyclotronCoil() { + return ModBlocks.blockCasings2Misc; + } + + public int getCyclotronCoilMeta() { + return 9; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Super Magnetic Speed Shooter") + .addSeparator() + .addInfo("Particles are accelerated over 186 revolutions to 80% light speed") + .addInfo("Can produce a continuous beam current of 2.2 mA at 590 MeV") + .addInfo("Which will be extracted from the Isochronous Cyclotron") + .addSeparator() + .addInfo("Consists of the same layout as a Fusion Reactor") + .addInfo("Any external casing can be a hatch/bus, unlike Fusion") + .addInfo("Cyclotron Machine Casings around Cyclotron Coil Blocks") + .addInfo("All Hatches must be IV or better") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfoMin("Cyclotron Machine Casings", 40, false) + .addCasingInfoMin("Cyclotron Coil", 32, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return getIconOverlay(); + } + + @Override + protected IIconContainer getInactiveOverlay() { + return getIconOverlay(); + } + + @Override + protected int getCasingTextureId() { + return 44; + } + + public IIconContainer getIconOverlay() { + if (this.getBaseMetaTileEntity() + .isActive()) { + return TexturesGtBlock.Overlay_MatterFab_Active_Animated; + } + return TexturesGtBlock.Overlay_MatterFab_Animated; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.cyclotronRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (result.wasSuccessful()) { + for (ItemStack s : outputItems) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState( + s, + MathUtils.getRandomFromArray( + new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, + -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, + 5, 5, 5, 6, 6 })); + } + } + } + } + } + return result; + } + }; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mOutputBusses.size() > 0) { + for (MTEHatchOutputBus g : this.mOutputBusses) { + if (g != null) { + for (ItemStack s : g.mInventory) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState( + s, + MathUtils.getRandomFromArray( + new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, + -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, + 5, 5, 5, 6, 6 })); + } + } + } + } + } + } + } + return super.onRunningTick(aStack); + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiCyclotron; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + String tier = tier() == 5 ? "I" : "II"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "COMET - Compact Cyclotron MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore() }; + } + + @Override + public boolean doesBindPlayerInventory() { + return false; + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java new file mode 100644 index 0000000000..676b6e817a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java @@ -0,0 +1,352 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Collections; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchElementalDataOrbHolder; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEElementalDuplicator extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private final ArrayList mReplicatorDataOrbHatches = new ArrayList<>(); + private static final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 3); + private int mCasing = 0; + + public MTEElementalDuplicator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEElementalDuplicator(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEElementalDuplicator(this.mName); + } + + @Override + public String getMachineType() { + return "Replicator"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Produces Elemental Material from UU Matter") + .addInfo("Speed: +100% | EU Usage: 100% | Parallel: 8 * Tier") + .addInfo("Maximum 1x of each bus/hatch.") + .addInfo("Requires circuit 1-16 in your Data Orb Repository") + .addInfo("depending on what Data Orb you want to prioritize") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 6, 9, true) + .addController("Top Center") + .addCasingInfoMin("Elemental Confinement Shell", 138, false) + .addCasingInfoMin("Matter Fabricator Casing", 24, false) + .addCasingInfoMin("Particle Containment Casing", 24, false) + .addCasingInfoMin("Matter Generation Coil", 24, false) + .addCasingInfoMin("High Voltage Current Capacitor", 20, false) + .addCasingInfoMin("Resonance Chamber III", 24, false) + .addCasingInfoMin("Modulator III", 16, false) + .addOtherStructurePart("Data Orb Repository", "1x", 1) + .addInputHatch("Any 1 dot hint", 1) + .addOutputBus("Any 1 dot hint", 1) + .addOutputHatch("Any 1 dot hint", 1) + .addEnergyHatch("Any 1 dot hint", 1) + .addMaintenanceHatch("Any 1 dot hint", 1) + .addMufflerHatch("Any 1 dot hint", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + + // h = Hatch + // c = Casing + + // a = MF Casing 1 + // b = Matter Gen Coil + + // d = Current Capacitor + // e = Particle + + // f = Resonance III + // g = Modulator III + + .addShape( + STRUCTURE_PIECE_MAIN, + (new String[][] { + { " ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccch~hccc", "ccchhhccc", " ccccccc ", + " ccccc ", " ccc " }, + { " cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", + " abfba ", " cac " }, + { " cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", + " e e ", " cec " }, + { " cec ", " e e ", " e e ", "c d c", "e ddd e", "c d c", " e e ", + " e e ", " cec " }, + { " cac ", " abfba ", " abfgfba ", "cbfgdgfbc", "afgdddgfa", "cbfgdgfbc", " abfgfba ", + " abfba ", " cac " }, + { " ccc ", " ccccc ", " ccccccc ", "ccchhhccc", "ccchhhccc", "ccchhhccc", " ccccccc ", + " ccccc ", " ccc " }, })) + .addElement('a', ofBlock(getCasingBlock4(), getCasingMeta6())) + .addElement('b', ofBlock(getCasingBlock4(), getCasingMeta7())) + .addElement('d', ofBlock(getCasingBlock2(), getCasingMeta2())) + .addElement('e', ofBlock(getCasingBlock2(), getCasingMeta3())) + .addElement('f', ofBlock(getCasingBlock3(), getCasingMeta4())) + .addElement('g', ofBlock(getCasingBlock3(), getCasingMeta5())) + .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement( + 'h', + lazy( + t -> ofChain( + buildHatchAdder(MTEElementalDuplicator.class) + .atLeast(InputHatch, OutputBus, OutputHatch, Maintenance, Muffler, Energy) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + buildHatchAdder(MTEElementalDuplicator.class) + .hatchClass(MTEHatchElementalDataOrbHolder.class) + .shouldReject(x -> x.mReplicatorDataOrbHatches.size() >= 1) + .adder(MTEElementalDuplicator::addDataOrbHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta()))))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 4, 4, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aDidBuild = checkPiece(STRUCTURE_PIECE_MAIN, 4, 4, 0); + if (this.mInputHatches.size() != 1 || (this.mOutputBusses.size() != 1 && this.mOutputHatches.size() != 0) + || this.mEnergyHatches.size() != 1 + || this.mReplicatorDataOrbHatches.size() != 1) { + return false; + } + log("Casings: " + mCasing); + return aDidBuild && mCasing >= 138 && checkHatch(); + } + + @Override + public int survivalConstruct(ItemStack itemStack, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, itemStack, 4, 4, 0, elementBudget, env, false, true); + } + + protected static int getCasingTextureIndex() { + return CASING_TEXTURE_ID; + } + + protected static Block getCasingBlock() { + return ModBlocks.blockCasings5Misc; + } + + protected static Block getCasingBlock2() { + return ModBlocks.blockSpecialMultiCasings; + } + + protected static Block getCasingBlock3() { + return ModBlocks.blockSpecialMultiCasings2; + } + + protected static Block getCasingBlock4() { + return ModBlocks.blockCasingsMisc; + } + + protected static int getCasingMeta() { + return 3; + } + + protected static int getCasingMeta2() { + return 12; + } + + protected static int getCasingMeta3() { + return 13; + } + + protected static int getCasingMeta4() { + return 2; + } + + protected static int getCasingMeta5() { + return 6; + } + + protected static int getCasingMeta6() { + return 9; + } + + protected static int getCasingMeta7() { + return 8; + } + + private boolean addDataOrbHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchElementalDataOrbHolder) { + try { + return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d == ForgeDirection.UP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAElementalDuplicatorActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAElementalDuplicator; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.replicatorRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2F) + .enablePerfectOverclock() + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + for (MTEHatchElementalDataOrbHolder hatch : filterValidMTEs(mReplicatorDataOrbHatches)) { + ItemStack orb = hatch.getOrbByCircuit(); + logic.setSpecialSlotItem(orb); + break; + } + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiMolecularTransformer; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mReplicatorDataOrbHatches.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + for (MTEHatchElementalDataOrbHolder tHatch : filterValidMTEs(mReplicatorDataOrbHatches)) { + tItems.add(tHatch.getOrbByCircuit()); + } + tItems.removeAll(Collections.singleton(null)); + return tItems; + } + + @Override + public boolean doesBindPlayerInventory() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEFrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEFrothFlotationCell.java new file mode 100644 index 0000000000..8e052870fa --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEFrothFlotationCell.java @@ -0,0 +1,286 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.List; +import java.util.Objects; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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.FakeSyncWidget; + +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; + +public class MTEFrothFlotationCell extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEFrothFlotationCell(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEFrothFlotationCell(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEFrothFlotationCell(this.mName); + } + + @Override + public String getMachineType() { + return "Flotation Cell"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Process that milled ore!") + .addInfo("You can only ever process one type of material per controller") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 9, 7, true) + .addController("Front Center") + .addCasingInfoMin("Inconel Reinforced Casing", 68, false) + .addCasingInfoMin("Flotation Casing", 52, false) + .addInputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDFrothFlotationCellActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDFrothFlotationCell; + } + + @Override + protected int getCasingTextureId() { + return TAE.getIndexFromPage(2, 1); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.flotationCellRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + new String[][] { { " ", " ", " X ", " X~X ", " X ", " ", " " }, + { " ", " F ", " FFF ", " FF FF ", " FFF ", " F ", " " }, + { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, + { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, + { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, + { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, + { " ", " F ", " F F ", " F F ", " F F ", " F ", " " }, + { " CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC " }, + { " CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC " }, }) + .addElement( + 'C', + buildHatchAdder(MTEFrothFlotationCell.class) + .atLeast(InputBus, InputHatch, OutputHatch, Maintenance, Energy) + .casingIndex(getCasingTextureId()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings3Misc, 1)))) + .addElement('F', ofBlock(ModBlocks.blockSpecialMultiCasings, 9)) + .addElement('X', ofBlock(ModBlocks.blockCasings3Misc, 1)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 3, 3, 0) && mCasing >= 68 - 4 && checkHatch(); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d == ForgeDirection.UP; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + /* + * Material checks Makes sure we can only ever use one type of material in this flotation cell. We used + * to depend on Alk's hash, but it's unreliable and user-hostile So we're using unlocalized name of + * material now. + */ + Material foundMaterial = FlotationRecipeHandler + .getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(recipe)); + String foundMaterialName = null; + if (foundMaterial != null) { + foundMaterialName = foundMaterial.getUnlocalizedName(); + } + + if (foundMaterialName == null) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + // Set material locked for this controller + if (lockedMaterialName == null) { + lockedMaterialName = foundMaterialName; + } + + // Check material match + if (!Objects.equals(lockedMaterialName, foundMaterialName)) { + return SimpleCheckRecipeResult.ofFailure("machine_locked_to_different_recipe"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }.enablePerfectOverclock(); + } + + /* + * Handle NBT + */ + + private String lockedMaterialName = null; + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (lockedMaterialName != null) { + aNBT.setString("lockedMaterialName", lockedMaterialName); + } + super.setItemNBT(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (lockedMaterialName != null) { + aNBT.setString("lockedMaterialName", lockedMaterialName); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("lockedMaterialName", Constants.NBT.TAG_STRING)) { + lockedMaterialName = aNBT.getString("lockedMaterialName"); + } + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + if (stack.hasTagCompound() && stack.getTagCompound() + .hasKey("lockedMaterialName")) { + tooltip.add( + StatCollector.translateToLocal("tooltip.flotationCell.lockedTo") + " " + + StatCollector.translateToLocal( + stack.getTagCompound() + .getString("lockedMaterialName"))); + } + } + + @Override + public String[] getExtraInfoData() { + return new String[] { "Locked material: " + lockedMaterialName }; + } + + @Override + public boolean isRecipeLockingEnabled() { + return lockedMaterialName != null && !lockedMaterialName.equals(""); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(new FakeSyncWidget.StringSyncer(() -> lockedMaterialName, val -> lockedMaterialName = val)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java new file mode 100644 index 0000000000..3a7370cf25 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java @@ -0,0 +1,488 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +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.FishPondFakeRecipe; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.ParallelHelper; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; + +public class MTEIndustrialFishingPond extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private boolean isUsingControllerCircuit = false; + private static final Item circuit = GTUtility.getIntegratedCircuit(0) + .getItem(); + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + private static final Class cofhWater; + + static { + cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + } + + public MTEIndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialFishingPond(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialFishingPond(this.mName); + } + + @Override + public String getMachineType() { + return "Fish Trap"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fishing Pond") + .addInfo("Can process (Tier + 1) * 2 recipes") + .addInfo("Put a numbered circuit into the input bus.") + .addInfo("Circuit 14 for Fish") + .addInfo("Circuit 15 for Junk") + .addInfo("Circuit 16 for Treasure") + .addInfo("Need to be filled with water.") + .addInfo("Will automatically fill water from input hatch.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfoMin("Aquatic Casings", 64, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { + { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", + "X X", "XXXXXXXXX" }, + { "XXXX~XXXX", "X X", "X X", "X X", "X X", "X X", "X X", + "X X", "XXXXXXXXX" }, + { "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", + "XXXXXXXXX", "XXXXXXXXX" }, })) + .addElement( + 'X', + buildHatchAdder(MTEIndustrialFishingPond.class) + .atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler, InputHatch) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 4, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 4, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 4, 1, 0) && mCasing >= 64 && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureIndex(); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.fishPondRecipes; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + ItemStack controllerStack = getControllerSlot(); + if (controllerStack != null) { + if (controllerStack.getItem() == circuit) { + this.isUsingControllerCircuit = true; + this.mMode = controllerStack.getItemDamage(); + } else { + this.isUsingControllerCircuit = false; + } + } else { + this.isUsingControllerCircuit = false; + } + if (!hasGenerateRecipes) { + generateRecipes(); + } + if (!checkForWater()) { + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + ItemStack[] tItemInputs = getStoredInputs().toArray(new ItemStack[0]); + FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); + + if (!isUsingControllerCircuit && tItemInputs.length == 0) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + long tEnergy = getMaxInputEnergy(); + + getCircuit(tItemInputs); + + ItemStack[] mFishOutput = generateLoot(this.mMode); + mFishOutput = removeNulls(mFishOutput); + GTRecipe g = new GTRecipe( + true, + new ItemStack[] {}, + mFishOutput, + null, + new int[] {}, + tFluidInputs, + null, + 200, + 16, + 0); + OverclockCalculator calculator = new OverclockCalculator().setRecipeEUt(g.mEUt) + .setEUt(tEnergy) + .setDuration(g.mDuration); + ParallelHelper helper = new ParallelHelper().setRecipe(g) + .setItemInputs(tItemInputs) + .setFluidInputs(tFluidInputs) + .setAvailableEUt(tEnergy) + .setMaxParallel(getMaxParallelRecipes()) + .setConsumption(true) + .setOutputCalculation(true) + .setMachine(this) + .enableBatchMode(batchMode ? 128 : 1) + .setCalculator(calculator); + + helper.build(); + + if (helper.getCurrentParallel() == 0) { + return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; + } + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + lEUt = -calculator.getConsumption(); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); + + mOutputItems = helper.getItemOutputs(); + mOutputFluids = null; + updateSlots(); + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Override + public int getMaxParallelRecipes() { + return (2 * (GTUtility.getTier(this.getMaxInputVoltage()) + 1)); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public int getCasingTextureIndex() { + return TAE.GTPP_INDEX(32); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (isNotStaticWater(tBlock, tMeta)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + } + } + } + } + + return tAmount >= 60; + } + + private boolean isNotStaticWater(Block block, byte meta) { + return block == Blocks.air || block == Blocks.flowing_water + || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) + || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); + } + + private static AutoMap> categories = new AutoMap<>(); + private static AutoMap categoryFish = new AutoMap<>(); + private static AutoMap categoryJunk = new AutoMap<>(); + private static AutoMap categoryLoot = new AutoMap<>(); + private static boolean hasGenerateRecipes = false; + private int mMode = 14; + private int mMax = 8; + + private void generateRecipes() { + if (hasGenerateRecipes) return; + + categories.put(categoryFish); + categories.put(categoryJunk); + categories.put(categoryLoot); + for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { + categoryFish.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { + categoryJunk.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { + categoryLoot.put(h); + } + hasGenerateRecipes = true; + } + + private int getCircuit(ItemStack[] t) { + if (!this.isUsingControllerCircuit) { + for (ItemStack j : t) { + if (j.getItem() == GTUtility.getIntegratedCircuit(0) + .getItem()) { + // Fish + if (j.getItemDamage() == 14) { + mMax = 8 + (this.getMaxParallelRecipes() - 2); + this.mMode = 14; + break; + } + // Junk + else if (j.getItemDamage() == 15) { + this.mMode = 15; + mMax = 4; + break; + } + // Loot + else if (j.getItemDamage() == 16) { + this.mMode = 16; + mMax = 4; + break; + } else { + this.mMode = 0; + mMax = 0; + break; + } + } else { + this.mMode = 0; + mMax = 0; + break; + } + } + } + return this.mMode; + } + + // reflection map + private static Map reflectiveFishMap = new HashMap<>(); + + private ItemStack reflectiveFish(WeightedRandomFishable y) { + if (reflectiveFishMap.containsKey(y)) { + return reflectiveFishMap.get(y); + } + ItemStack t; + try { + t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b") + .get(y); + ItemStack k = ItemUtils.getSimpleStack(t, 1); + reflectiveFishMap.put(y, k); + return t; + } catch (IllegalArgumentException | IllegalAccessException e) {} + return null; + } + + private ItemStack[] generateLoot(int mode) { + ItemStack[] mFishOutput = new ItemStack[this.mMax]; + if (this.mMode == 14) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryFish.values()) { + if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 15) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryJunk.values()) { + if (MathUtils.randInt(0, 100) <= 1) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 16) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryLoot.values()) { + if (MathUtils.randInt(0, 1000) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else { + mFishOutput = null; + } + return mFishOutput; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialRockBreaker.java new file mode 100644 index 0000000000..4b91b42d9f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialRockBreaker.java @@ -0,0 +1,366 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +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.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.ParallelHelper; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEIndustrialRockBreaker extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEIndustrialRockBreaker(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEIndustrialRockBreaker(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEIndustrialRockBreaker(this.mName); + } + + @Override + public String getMachineType() { + return "Rock Breaker"; + } + + private static final String casingBaseName = GTLanguageManager.getTranslation("gtplusplus.blockcasings.2.0.name"); + private static final String casingMiddleName = GTLanguageManager + .getTranslation("gtplusplus.blockcasings.2.11.name"); + private static final String anyBaseCasing = "Any " + casingBaseName; + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Rock Breaker") + .addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 8") + .addInfo("Circuit goes in the GUI slot") + .addInfo("1 = cobble, 2 = stone, 3 = obsidian") + .addInfo("Needs Water and Lava in input hatch") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfoMin(casingBaseName, 9, false) + .addCasingInfoExactly(casingMiddleName, 16, false) + .addInputBus(anyBaseCasing, 1) + .addInputHatch(anyBaseCasing, 1) + .addOutputBus(anyBaseCasing, 1) + .addEnergyHatch(anyBaseCasing, 1) + .addMaintenanceHatch(anyBaseCasing, 1) + .addMufflerHatch(anyBaseCasing, 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "HHH", "H-H", "HHH" }, { "HHH", "H-H", "HHH" }, + { "C~C", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEIndustrialRockBreaker.class) + .atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(16)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 0)))) + .addElement('H', ofBlock(ModBlocks.blockCasings2Misc, 11)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + boolean aCheckPiece = checkPiece(mName, 1, 3, 0); + boolean aCasingCount = mCasing >= 9; + boolean aCheckHatch = checkHatch(); + log("" + aCheckPiece + ", " + aCasingCount + ", " + aCheckHatch); + return aCheckPiece && aCasingCount && aCheckHatch; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_INDUCTION_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAIndustrialRockBreakerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAIndustrialRockBreaker; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(16); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.rockBreakerFakeRecipes; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + private static GTRecipe sRecipe_Cobblestone; + private static GTRecipe sRecipe_SmoothStone; + private static GTRecipe sRecipe_Redstone; + + private static void generateRecipes() { + sRecipe_Cobblestone = new GTRecipe( + false, + new ItemStack[] { GTUtility.getIntegratedCircuit(1) }, + new ItemStack[] { ItemUtils.getSimpleStack(Blocks.cobblestone) }, + null, + new int[] { 10000 }, + null, + null, + 16, + 32, + 0); + sRecipe_SmoothStone = new GTRecipe( + false, + new ItemStack[] { GTUtility.getIntegratedCircuit(2) }, + new ItemStack[] { ItemUtils.getSimpleStack(Blocks.stone) }, + null, + new int[] { 10000 }, + null, + null, + 16, + 32, + 0); + sRecipe_Redstone = new GTRecipe( + false, + new ItemStack[] { GTUtility.getIntegratedCircuit(3), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) }, + new ItemStack[] { ItemUtils.getSimpleStack(Blocks.obsidian) }, + null, + new int[] { 10000 }, + null, + null, + 128, + 32, + 0); + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + ArrayList aFluids = this.getStoredFluids(); + if (aFluids.isEmpty()) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + boolean aHasWater = false; + boolean aHasLava = false; + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid() == FluidRegistry.WATER) { + aHasWater = true; + } else if (aFluid.getFluid() == FluidRegistry.LAVA) { + aHasLava = true; + } + } + ArrayList aItems = this.getStoredInputs(); + boolean aHasRedstone = false; + if (!aItems.isEmpty()) { + for (ItemStack aItem : aItems) { + if (GTUtility + .areStacksEqual(aItem, GTOreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) { + aHasRedstone = true; + break; + } + } + } + + if (!aHasWater) { + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + if (!aHasLava) { + return SimpleCheckRecipeResult.ofFailure("no_lava"); + } + ItemStack aGuiCircuit = this.getControllerSlot(); + if (!ItemUtils.isControlCircuit(aGuiCircuit)) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { + generateRecipes(); + } + + int aCircuit = aGuiCircuit.getItemDamage(); + + GTRecipe tRecipe = null; + switch (aCircuit) { + case 1 -> tRecipe = sRecipe_Cobblestone; + case 2 -> tRecipe = sRecipe_SmoothStone; + case 3 -> { + if (aHasRedstone) { + tRecipe = sRecipe_Redstone; + } + } + } + + if (tRecipe == null) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[0]); + FluidStack[] aFluidInputs = new FluidStack[] {}; + + long tEnergy = getMaxInputEnergy(); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + ParallelHelper helper = new ParallelHelper().setRecipe(tRecipe) + .setItemInputs(aItemInputs) + .setFluidInputs(aFluidInputs) + .setAvailableEUt(tEnergy) + .setMaxParallel(getMaxParallelRecipes()) + .setConsumption(true) + .setOutputCalculation(true) + .setEUtModifier(0.75F) + .setMachine(this); + + if (batchMode) { + helper.enableBatchMode(128); + } + + helper.build(); + + if (helper.getCurrentParallel() == 0) { + return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; + } + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + OverclockCalculator calculator = new OverclockCalculator().setRecipeEUt(tRecipe.mEUt) + .setEUt(tEnergy) + .setDuration(tRecipe.mDuration) + .setEUtDiscount(0.75F) + .setSpeedBoost(1F / 3F) + .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplierDouble())) + .calculate(); + lEUt = -calculator.getConsumption(); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); + + mOutputItems = helper.getItemOutputs(); + mOutputFluids = helper.getFluidOutputs(); + updateSlots(); + return CheckRecipeResultRegistry.SUCCESSFUL; + + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GTUtility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiIndustrialRockBreaker; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public ArrayList getStoredInputs() { + ArrayList aInputs = super.getStoredInputs(); + if (this.getControllerSlot() != null) { + aInputs.add(this.getControllerSlot()); + } + return aInputs; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java new file mode 100644 index 0000000000..3a5bbaa42a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java @@ -0,0 +1,523 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.AirIntake; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTDynamo; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.google.common.collect.ImmutableMap; +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 gregtech.api.enums.GTValues; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +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.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.RocketFuels; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.material.MaterialMisc; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.METHatchAirIntake; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTELargeRocketEngine extends GTPPMultiBlockBase implements ISurvivalConstructable { + + protected int fuelConsumption; + protected int fuelValue; + protected int fuelRemaining; + protected int freeFuelTicks = 0; + protected int euProduction = 0; + protected boolean boostEu; + + public static String mLubricantName = "Carbon Dioxide"; + public static String mCoolantName = "Liquid Hydrogen"; + + public static String mCasingName = "Turbodyne Casing"; + public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; + public static String mGearboxName = "Inconel Reinforced Casing"; + + private static Fluid sAirFluid = null; + private static FluidStack sAirFluidStack = null; + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final int CASING_ID = TAE.getIndexFromPage(3, 11); + + public MTELargeRocketEngine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + setAir(); + } + + public MTELargeRocketEngine(final String aName) { + super(aName); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + setAir(); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Rocket Engine") + .addInfo("Generating Power from Rocket Fuels - Supports TecTech Multi-Amp Dynamos!") + .addInfo("Supply GT++ Rocket Fuels and 1000L of " + mLubricantName + " per hour") + .addInfo("Produces as much energy as you put fuel in, with optional boosting") + .addInfo("This multi doesn't accept fluids if not enabled - enable it first!") + .addInfo("Consumes 2000L/s of air and pollutes 1500 gibbl/s per 16384 eu/t produced") + .addInfo("Place 1-8 Air Intake Hatches on the sides to maintain Air input") + .addInfo("If it runs out of air, it will shut down and have to be manually restarted") + .addInfo("Supply 3L of " + mCoolantName + " per second, per 1000 EU/t to boost") + .addInfo("Takes 3x the amount of " + mLubricantName + " and maintains efficiency") + .addInfo("Fuel efficiency starts at ~160%, falls more slowly at higher EU/t if boosted") + .addInfo("If producing more than 30k EU/t, fuel efficiency will be lower:") + .addInfo("(These thresholds are 3x higher when boosted, boosted values displayed second)") + .addInfo("- 75% of max fuel efficiency at 53k or 159k EU/t output energy") + .addInfo("- 50% of max fuel efficiency at 69k or 207k EU/t output energy") + .addInfo("- 25% of max fuel efficiency at 98k or 294k EU/t output energy") + .addInfo("formula: x = input of energy (30000^(1/3)/ x^(1/3)) * (80000^(1/3)/ x^(1/3))") + .addSeparator() + .beginStructureBlock(3, 3, 10, false) + .addController("Front Center") + .addCasingInfoMin(mCasingName, 64, false) + .addCasingInfoMin(mGearboxName, 8, false) + .addStructureHint("Air Intake Hatch", 1) + .addInputBus("Side center line", 1) + .addInputHatch("Side center line", 1) + .addMaintenanceHatch("Any Block Touching Inconel Reinforced Casing", 1) + .addDynamoHatch("Top center line", 2) + .addMufflerHatch("Back Center", 3) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (this.STRUCTURE_DEFINITION == null) { + this.STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + this.mName, + transpose( + new String[][] { { "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC" }, + { "C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC" }, + { "CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC" }, })) + .addElement('C', ofBlock(getCasingBlock(), getCasingMeta())) + .addElement('I', ofBlock(getGearboxBlock(), getGearboxMeta())) + // side + .addElement( + 'S', + buildHatchAdder(MTELargeRocketEngine.class) + .atLeast(ImmutableMap.of(AirIntake, 8, InputBus, 1, InputHatch, 3, Maintenance, 1)) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + // top + .addElement( + 'T', + buildHatchAdder(MTELargeRocketEngine.class) + .atLeast(ImmutableMap.of(AirIntake, 8, Dynamo.or(TTDynamo), 1, Maintenance, 1)) + .casingIndex(getCasingTextureIndex()) + .dot(2) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('M', Muffler.newAny(getCasingTextureIndex(), 3)) + .build(); + } + return this.STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(this.mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mCasing = 0; + this.mTecTechDynamoHatches.clear(); + this.mAllDynamoHatches.clear(); + this.mAirIntakes.clear(); + return checkPiece(this.mName, 1, 1, 0) && this.mCasing >= 64 - 48 + && this.mAirIntakes.size() >= 1 + && checkHatch(); + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCALargeRocketEngineActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCALargeRocketEngine; + } + + @Override + protected int getCasingTextureId() { + return CASING_ID; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return this.getMaxEfficiency(aStack) > 0; + } + + public static void setAir() { + if (sAirFluidStack == null) { + sAirFluidStack = FluidUtils.getFluidStack("air", 1); + } + if (sAirFluid == null && sAirFluidStack != null) { + sAirFluid = sAirFluidStack.getFluid(); + } + } + + public int getAir() { + setAir(); + if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) { + return 0; + } else { + int totalAir = 0; + for (METHatchAirIntake u : this.mAirIntakes) { + if (u != null && u.mFluid != null) { + FluidStack f = u.mFluid; + if (f.isFluidEqual(sAirFluidStack)) { + totalAir += f.amount; + } + } + } + return totalAir; + } + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.rocketFuels; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + final ArrayList tFluids = this.getStoredFluids(); + this.clearRecipeMapForAllInputHatches(); + int aircount = getAir(); + int aAirToConsume = this.euProduction / 100; + if (aircount < aAirToConsume) { + stopMachine(ShutDownReasonRegistry.outOfFluid(new FluidStack(sAirFluid, aAirToConsume))); + return SimpleCheckRecipeResult.ofFailure("no_air"); + } else { + int aTotalAir = 0; + for (METHatchAirIntake aAirHatch : this.mAirIntakes) { + if (aAirHatch.mFluid != null) { + aTotalAir += aAirHatch.getFluidAmount(); + } + } + if (aTotalAir >= aAirToConsume) { + int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); + if (aSplitAmount > 0) { + for (METHatchAirIntake aAirHatch : mAirIntakes) { + boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; + if (!hasIntakeAir) { + this.freeFuelTicks = 0; + return SimpleCheckRecipeResult.ofFailure("no_air"); + } + } + } + } + } + // reset fuel ticks in case it does not reset when it stops + if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) this.freeFuelTicks = 0; + + if (tFluids.size() > 0 && getRecipeMap() != null) { + if (this.mRuntime % 72 == 0) { + if (!consumeCO2()) { + this.freeFuelTicks = 0; + return SimpleCheckRecipeResult.ofFailure("no_co2"); + } + } + if (this.freeFuelTicks == 0) { + this.boostEu = consumeLOH(); + } + for (final FluidStack hatchFluid1 : tFluids) { + if (hatchFluid1.isFluidEqual(sAirFluidStack)) { + continue; + } + if (this.freeFuelTicks == 0) { + for (final GTRecipe aFuel : getRecipeMap().getAllRecipes()) { + final FluidStack tLiquid; + tLiquid = aFuel.mFluidInputs[0]; + if (hatchFluid1.isFluidEqual(tLiquid)) { + if (!consumeFuel(aFuel, hatchFluid1.amount)) { + continue; + } + this.fuelValue = aFuel.mSpecialValue * 3; + this.fuelRemaining = hatchFluid1.amount; + this.lEUt = ((this.mEfficiency < 2000) ? 0 : GTValues.V[5] << 1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = this.euProduction / 2000; + return CheckRecipeResultRegistry.GENERATING; + } + } + } else { + this.mEfficiencyIncrease = this.euProduction / 2000; + this.freeFuelTicks--; + this.lEUt = ((this.mEfficiency < 1000) ? 0 : GTValues.V[5] << 1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + return CheckRecipeResultRegistry.GENERATING; + } + } + } + this.lEUt = 0; + this.mEfficiency = 0; + this.freeFuelTicks = 0; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + + /** + * Consumes Fuel if required. Free Fuel Ticks are handled here. + * + * @param aFuel + * @return + */ + public boolean consumeFuel(GTRecipe aFuel, int amount) { + amount *= this.boostEu ? 0.3 : 0.9; + this.freeFuelTicks = 0; + int value = aFuel.mSpecialValue * 3; + int energy = value * amount; + if (amount < 5) return false; + FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); + if (!this.depleteInput(tLiquid)) { + return false; + } else { + this.fuelConsumption = this.boostEu ? amount * 3 : amount; + this.freeFuelTicks = 20; + setEUProduction(energy); + return true; + } + } + + public void setEUProduction(int energy) { + energy /= 20; + double energyEfficiency; + double tDivideEnergy = Math.cbrt(energy); + if (energy > 30000) { + // cbrt(30 000) / + energyEfficiency = (31.072325 / tDivideEnergy); + if (energy >= 80000) + // cbrt(80 000) / + energyEfficiency *= (43.0886938 / tDivideEnergy); + energyEfficiency *= energy; + } else { + energyEfficiency = energy; + } + this.euProduction = (int) (energyEfficiency); + if (this.boostEu) this.euProduction *= 3; + } + + public boolean consumeCO2() { + return this.depleteInput(MaterialMisc.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) + || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1))); + } + + public boolean consumeLOH() { + int LOHamount = (3 * this.euProduction) / 1000; + return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); // (40 * ((long) + // euProduction / + // 10000)) + } + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + @Override + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (MTEHatch aDynamo : filterValidMTEs(this.mAllDynamoHatches)) { + long aVoltage = aDynamo.maxEUOutput(); + long aTotal = aDynamo.maxAmperesOut() * aVoltage; + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + aFirstVoltageFound = aVoltage; + } else { + if (aFirstVoltageFound != aVoltage) { + aFoundMixedDynamos = true; + } + } + totalOutput += aTotal; + } + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + long aVoltage; + int aAmpsToInject; + int aRemainder; + + for (MTEHatch aDynamo : filterValidMTEs(this.mAllDynamoHatches)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + long powerGain; + for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { + if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)) { + powerGain = aRemainder; + } else { + powerGain = aVoltage; + } + aDynamo.getBaseMetaTileEntity() + .increaseStoredEnergyUnits(powerGain, false); + injected += powerGain; + } + } + return injected > 0; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public byte getCasingMeta() { + return 11; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getGearboxMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) CASING_ID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTELargeRocketEngine(this.mName); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("freeFuelTicks", this.freeFuelTicks); + aNBT.setInteger("euProduction", this.euProduction); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.freeFuelTicks = aNBT.getInteger("freeFuelTicks"); + this.euProduction = aNBT.getInteger("euProduction"); + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return this.euProduction; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 75 * (this.euProduction / 10000); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { "Rocket Engine", "Current Air: " + getAir(), + "Current Pollution: " + getPollutionPerTick(null), + "Time until next fuel consumption: " + this.freeFuelTicks, + "Current Output: " + this.lEUt * this.mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + (this.fuelConsumption) + "L/s", "Fuel Value: " + this.fuelValue + " EU/L", + "Fuel Remaining: " + this.fuelRemaining + " Litres", "Current Efficiency: " + this.mEfficiency / 100 + "%", + (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String getMachineType() { + return "Rocket Engine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public boolean doesBindPlayerInventory() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeSemifluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeSemifluidGenerator.java new file mode 100644 index 0000000000..141fbff41f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeSemifluidGenerator.java @@ -0,0 +1,331 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTDynamo; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTELargeSemifluidGenerator extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + public MTELargeSemifluidGenerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeSemifluidGenerator(String aName) { + super(aName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Semifluid Generator") + .addInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") + .addInfo("Supply Semifluid Fuels and 2000L of Lubricant per hour to run.") + .addInfo("Supply 80L of Oxygen per second to boost output (optional).") + .addInfo("Default: Produces 2048EU/t at 100% efficiency") + .addInfo("Boosted: Produces 6144EU/t at 150% efficiency") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, false) + .addController("Front Center") + .addCasingInfoMin("Stable Titanium Machine Casing", 16, false) + .addCasingInfoMin("Steel Gear Box Machine Casing", 2, false) + .addCasingInfoMin("Engine Intake Machine Casing", 8, false) + .addInputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addDynamoHatch("Back Center", 2) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; + } + + @Override + protected int getCasingTextureId() { + return 50; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + ArrayList tFluids = getStoredFluids(); + + // Check for lubricant and oxygen first, so we can compute costs ahead of time. + // This will allow us to check costs without needing to actually try to deplete fluids + // (wasting earlier fluids in the check if later fluids turn out to be insufficient). + FluidStack lubricant = Materials.Lubricant.getFluid(0L); + FluidStack oxygen = Materials.Oxygen.getGas(0L); + for (FluidStack hatchFluid : tFluids) { + if (hatchFluid.isFluidEqual(lubricant)) { + lubricant.amount = Math.max(lubricant.amount, hatchFluid.amount); + } else if (hatchFluid.isFluidEqual(oxygen)) { + oxygen.amount = Math.max(oxygen.amount, hatchFluid.amount); + } + } + boostEu = oxygen.amount >= 4L; + long lubricantCost = boostEu ? 2L : 1L; + if (lubricant.amount < lubricantCost) { + return SimpleCheckRecipeResult.ofFailure("no_lubricant"); + } + + for (FluidStack hatchFluid : tFluids) { // Loops through hatches + GTRecipe aFuel = GTPPRecipeMaps.semiFluidFuels.getBackend() + .findFuel(hatchFluid); + if (aFuel == null) { + // Not a valid semi-fluid fuel. + continue; + } + + int newEUt = boostEu ? 4096 : 2048; + fuelConsumption = newEUt / aFuel.mSpecialValue; // Calc fuel consumption + FluidStack tLiquid = new FluidStack(hatchFluid.getFluid(), fuelConsumption); + if (depleteInput(tLiquid)) { // Deplete that amount + // We checked beforehand, so both of these depletions should succeed. + // But check the return values anyway just to be safe. + if (boostEu) { + if (!depleteInput(Materials.Oxygen.getGas(4L))) { + return SimpleCheckRecipeResult.ofFailure("no_oxygen"); + } + } + // Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) + if (mRuntime % 72 == 0 || mRuntime == 0) { + if (!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { + return SimpleCheckRecipeResult.ofFailure("no_lubricant"); + } + } + + fuelValue = aFuel.mSpecialValue; + fuelRemaining = hatchFluid.amount; // Record available fuel + this.lEUt = mEfficiency < 2000 ? 0 : newEUt; // Output 0 if startup is less than 20% + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 15; + return CheckRecipeResultRegistry.GENERATING; + } + } + + this.lEUt = 0; + this.mEfficiency = 0; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "III", "CCC", "CCC", "CCC" }, { "I~I", "CGC", "CGC", "CMC" }, + { "III", "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTELargeSemifluidGenerator.class).atLeast(Muffler, InputHatch, Maintenance) + .casingIndex(getCasingTextureIndex()) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('G', ofBlock(getGearboxBlock(), getGearboxMeta())) + .addElement('I', ofBlock(getIntakeBlock(), getIntakeMeta())) + .addElement( + 'M', + Dynamo.or(TTDynamo) + .newAny(getCasingTextureIndex(), 2)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mDynamoHatches.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 16 && checkHatch(); + } + + public final boolean addLargeSemifluidGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchMuffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchInput) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addLargeSemifluidGeneratorBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchDynamo || this.isThisHatchMultiDynamo(aTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public Block getCasingBlock() { + return GregTechAPI.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public Block getIntakeBlock() { + return GregTechAPI.sBlockCasings4; + } + + public byte getIntakeMeta() { + return 13; + } + + public Block getGearboxBlock() { + return GregTechAPI.sBlockCasings2; + } + + public byte getGearboxMeta() { + return 3; + } + + public byte getCasingTextureIndex() { + return 50; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeSemifluidGenerator(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return boostEu ? 15000 : 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { "Large Semifluid Generator", "Current Output: " + lEUt * mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + fuelConsumption + "L/t", "Fuel Value: " + fuelValue + " EU/L", + "Fuel Remaining: " + fuelRemaining + " Litres", "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String getMachineType() { + return "Semifluid Generator"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEMassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEMassFabricator.java new file mode 100644 index 0000000000..0bcf503daf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEMassFabricator.java @@ -0,0 +1,360 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +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 net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IIconContainer; +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.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.config.machinestats.ConfigMassFabricator; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTEMassFabricator extends GTPPMultiBlockBase implements ISurvivalConstructable { + + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3200; + + public static String mCasingName1 = "Matter Fabricator Casing"; + public static String mCasingName2 = "Containment Casing"; + public static String mCasingName3 = "Matter Generation Coil"; + + private int mMode = 0; + + private static final int MODE_SCRAP = 1; + private static final int MODE_UU = 0; + + public static boolean sRequiresUUA = false; + private static final FluidStack[] mUU = new FluidStack[2]; + private static final ItemStack[] mScrap = new ItemStack[2]; + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTEMassFabricator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMassFabricator(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Mass Fabricator / Recycler"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Matter Fabricator") + .addInfo("Speed: +0% | EU Usage: 80%") + .addInfo("Parallel: Scrap = 64 | UU = 8 * Tier") + .addInfo("Produces UU-A, UU-M & Scrap") + .addInfo("Change mode with screwdriver") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController("Front Center") + .addCasingInfoMin(mCasingName3, 9, false) + .addCasingInfoMin(mCasingName2, 24, false) + .addCasingInfoMin(mCasingName1, 36, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Active_Animated; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.Overlay_MatterFab_Animated; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(9); + } + + @Override + public void onConfigLoad() { + super.onConfigLoad(); + sDurationMultiplier = ConfigMassFabricator.durationMultiplier; + sUUAperUUM = ConfigMassFabricator.UUAPerUUM; + sUUASpeedBonus = ConfigMassFabricator.UUASpeedBonus; + sRequiresUUA = ConfigMassFabricator.requiresUUA; + } + + public static boolean sInit = false; + + public static void init() { + if (!sInit) { + if (mScrap[0] == null) { + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); + } + if (mScrap[1] == null) { + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); + } + if (mUU[0] == null) { + mUU[0] = Materials.UUAmplifier.getFluid(100); + } + if (mUU[1] == null) { + mUU[1] = Materials.UUMatter.getFluid(100); + } + sInit = true; + } + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, + { "CGGGC", "G---G", "G---G", "G---G", "CGGGC" }, + { "CGGGC", "G---G", "G---G", "G---G", "CGGGC" }, + { "CC~CC", "CHHHC", "CHHHC", "CHHHC", "CCCCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEMassFabricator.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler) + .casingIndex(TAE.GTPP_INDEX(9)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 9)))) + .addElement('H', ofBlock(ModBlocks.blockCasingsMisc, 8)) + .addElement('G', ofBlock(ModBlocks.blockCasings3Misc, 15)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 2, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 2, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 3, 0) && mCasing >= 36 && checkHatch(); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiMassFabricator; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEMassFabricator(this.mName); + } + + /** + * Special Recipe Handling + */ + @Override + public RecipeMap getRecipeMap() { + return this.mMode == MODE_SCRAP ? RecipeMaps.recyclerRecipes : GTPPRecipeMaps.multiblockMassFabricatorRecipes; + } + + @Nonnull + @Override + public Collection> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.recyclerRecipes, GTPPRecipeMaps.multiblockMassFabricatorRecipes); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + public CheckRecipeResult process() { + init(); + return super.process(); + } + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (mMode == MODE_SCRAP) { + if (recipe.mOutputs == null) { + return SimpleCheckRecipeResult.ofSuccess("no_scrap"); + } + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + if (mMode == MODE_SCRAP) { + if (inputItems != null) { + for (ItemStack item : inputItems) { + if (item == null || item.stackSize == 0) continue; + ItemStack aPotentialOutput = GTModHandler + .getRecyclerOutput(GTUtility.copyAmount(1, item), 0); + GTRecipe recipe = new GTRecipe( + false, + new ItemStack[] { GTUtility.copyAmount(1, item) }, + aPotentialOutput == null ? null : new ItemStack[] { aPotentialOutput }, + null, + new int[] { 2000 }, + null, + null, + 40, + (int) TierEU.RECIPE_LV, + 0); + return Stream.of(recipe); + } + } + return Stream.empty(); + } + return super.findRecipeMatches(map); + } + }.setEuModifier(0.8F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.enablePerfectOverclock(); + } + + @Override + public int getMaxParallelRecipes() { + return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GTUtility.getTier(getMaxInputVoltage()))); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + int aMode = this.mMode + 1; + if (aMode > 1) { + this.mMode = MODE_UU; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Matter/AmpliFabricator"); + } else if (aMode == 1) { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); + } else { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode [" + this.mMode + "]: Recycler"); + } + mLastRecipe = null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mMode = aNBT.getInteger("mMode"); + super.loadNBTData(aNBT); + } + + @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); + tag.setInteger("mode", mMode); + } + + @Override + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currentTip, accessor, config); + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("GT5U.GTPP_MULTI_MASS_FABRICATOR.mode." + tag.getInteger("mode")) + + EnumChatFormatting.RESET); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java new file mode 100644 index 0000000000..3da77cf783 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java @@ -0,0 +1,521 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTRecipeConstants.LFTR_OUTPUT_POWER; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.filterByMTETier; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.objects.GTItemStack; +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.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.material.MaterialsElements; +import gtPlusPlus.core.material.nuclear.MaterialsNuclides; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTENuclearReactor extends GTPPMultiBlockBase implements ISurvivalConstructable { + + protected int mFuelRemaining = 0; + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTENuclearReactor(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTENuclearReactor(final String aName) { + super(aName); + } + + @Override + public long maxEUStore() { + return (640000000L * (Math.min(16, this.mEnergyHatches.size()))) / 16L; + } + + @Override + public String getMachineType() { + return "Reactor"; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.liquidFluorineThoriumReactorRecipes; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") + .addInfo("Produces energy and new elements from Radioactive Beta Decay!") + .addInfo("Input LFTB and a molten salt as fuel, and match the 4 Buffered Dynamo Hatches:") + .addInfo("LFTR Fuel 1 (4 EV Hatches), LFTR Fuel 2 (4 IV Hatches), LFTR Fuel 3 (4 LuV Hatches)") + .addInfo("If using better hatches for a worse fuel, only 1 hatch will output EU") + .addInfo("Outputs U233 every 10 seconds, on average, while the reactor is running") + .addInfo("Check NEI to see the other 3 outputs - they differ between fuels") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 4, 7, true) + .addController("Bottom Center") + .addCasingInfoMin("Hastelloy-N Reactor Casing", 27, false) + .addCasingInfoMin("Zeron-100 Reactor Shielding", 26, false) + .addInputHatch("Top or bottom layer edges", 1) + .addOutputHatch("Top or bottom layer edges", 1) + .addDynamoHatch("Top or bottom layer edges", 1) + .addMufflerHatch("Top 3x3", 2) + .addStructureInfo("All dynamos must be between EV and LuV tier.") + .addStructureInfo("All other hatches must be IV+ tier.") + .addStructureInfo("4x Output Hatches or 1x Output Hatch (ME), 1+ Input Hatches") + .addStructureInfo("4x Dynamo Hatches, 4x Mufflers") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + public String[] getExtraInfoData() { + final String tRunning = (this.mMaxProgresstime > 0 ? "Reactor running" : "Reactor stopped"); + final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" + : "Needs Maintainance"); + + return new String[] { "Liquid Fluoride Thorium Reactor", tRunning, tMaintainance, + "Current Output: " + this.lEUt + " EU/t", "Fuel Remaining: " + this.mFuelRemaining + " Litres", + "Current Efficiency: " + (this.mEfficiency / 5) + "%", "Current Efficiency (Raw): " + (this.mEfficiency), + "It requires you to have 100% Efficiency." }; + } + + @Override + public boolean allowCoverOnSide(final ForgeDirection side, final GTItemStack aStack) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + boolean aWarmedUp = this.mEfficiency == this.getMaxEfficiency(null); + if (!aBaseMetaTileEntity.isActive() || !aWarmedUp) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR_ACTIVE) + .extFacing() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; + } else if (aBaseMetaTileEntity.isActive() && aWarmedUp) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR_ACTIVE) + .extFacing() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_NUCLEAR_REACTOR) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; + } + + public final boolean addNuclearReactorEdgeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchDynamo dynamo && dynamo.getTierForStructure() >= 4 + && dynamo.getTierForStructure() <= 6) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchInput hatch && hatch.getTierForStructure() >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchOutput hatch && hatch.getTierForStructure() >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addNuclearReactorTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchMuffler hatch && hatch.getTierForStructure() >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { + { "CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC" }, + { "GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG" }, + { "GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG" }, + { "CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTENuclearReactor.class).atLeast(Maintenance) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + buildHatchAdder(MTENuclearReactor.class).atLeast(InputHatch, OutputHatch) + .adder(MTENuclearReactor::addNuclearReactorEdgeList) + .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + buildHatchAdder(MTENuclearReactor.class).atLeast(Dynamo) + .adder(MTENuclearReactor::addNuclearReactorEdgeList) + .hatchItemFilterAnd(t -> filterByMTETier(4, 6)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) + .addElement( + 'X', + buildHatchAdder(MTENuclearReactor.class).atLeast(Muffler) + .adder(MTENuclearReactor::addNuclearReactorTopList) + .hatchItemFilterAnd(t -> filterByMTETier(5, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(12)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasingsMisc, 12)))) + .addElement('O', ofBlock(ModBlocks.blockCasingsMisc, 12)) + .addElement('G', ofBlock(ModBlocks.blockCasingsMisc, 13)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 3, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { + if ((mOutputHatches.size() >= 3 || canDumpFluidToME()) && mInputHatches.size() >= 1 + && mDynamoHatches.size() == 4 + && mMufflerHatches.size() == 4) { + this.turnCasingActive(false); + return true; + } + } + return false; + } + + // Alk's Life Lessons from Greg. + /* + * [23:41:15] xdir and zdir are x2 and not x3 [23:41:26] thats you + * issue [23:44:33] mmm? [23:44:49] Should they be x3? [23:44:50] you + * just do a x2, what is for a 5x5 multiblock [23:45:01] x3 is for a 7x7 one [23:45:06] + * I have no idea what that value does, tbh.. [23:45:15] its the offset [23:45:23] + * Debugging checkMachine has been a pain and I usually trash designs that don't work straight up.. + * [23:45:28] it determines the horizontal middle of the multiblock [23:45:47] + * which is in your case THREE blocks away from the controller [23:45:51] Ahh + * [23:45:57] and not 2 [23:46:06] Noted, thanks :D + */ + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTENuclearReactor(this.mName); + } + + public boolean turnCasingActive(final boolean status) { + // TODO + if (this.mDynamoHatches != null) { + for (final MTEHatchDynamo hatch : this.mDynamoHatches) { + hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); + } + } + if (this.mMufflerHatches != null) { + for (final MTEHatchMuffler hatch : this.mMufflerHatches) { + hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); + } + } + if (this.mOutputHatches != null) { + for (final MTEHatchOutput hatch : this.mOutputHatches) { + hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); + } + } + if (this.mInputHatches != null) { + for (final MTEHatchInput hatch : this.mInputHatches) { + hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); + } + } + if (this.mMaintenanceHatches != null) { + for (final MTEHatchMaintenance hatch : this.mMaintenanceHatches) { + hatch.updateTexture(status ? TAE.GTPP_INDEX(13) : TAE.GTPP_INDEX(12)); + } + } + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + return OverclockCalculator + .ofNoOverclock(recipe.getMetadataOrDefault(LFTR_OUTPUT_POWER, 0) * 4L, recipe.mDuration); + } + + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (!result.wasSuccessful()) { + resetMultiProcessing(); + } + return result; + } + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + mFuelRemaining = 0; + int li2bef4 = 0; + FluidStack aFuelFluid = null; + for (FluidStack aFluidInput : recipe.mFluidInputs) { + if (!aFluidInput.getFluid() + .equals(MaterialsNuclides.Li2BeF4.getFluid())) { + aFuelFluid = aFluidInput; + break; + } + } + if (aFuelFluid != null) { + for (FluidStack fluidStack : inputFluids) { + if (fluidStack.isFluidEqual(aFuelFluid)) { + mFuelRemaining += fluidStack.amount; + } else if (fluidStack.getFluid() + .equals(MaterialsNuclides.Li2BeF4.getFluid())) { + li2bef4 += fluidStack.amount; + } + } + } + if (mFuelRemaining < 100) { + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + if (li2bef4 < 200) { + return SimpleCheckRecipeResult.ofFailure("no_li2bef4"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }; + } + + protected void resetMultiProcessing() { + this.mEfficiency = 0; + this.mLastRecipe = null; + stopMachine(ShutDownReasonRegistry.NONE); + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + // Warm up for 4~ minutes + if (mEfficiency < this.getMaxEfficiency(null)) { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 2; + this.lEUt = 0; + return SimpleCheckRecipeResult.ofSuccess("warm_up"); + } + CheckRecipeResult result = super.checkProcessing(); + if (result.wasSuccessful()) { + // We produce EU, so we negate the value, if negative + if (lEUt < 0) { + lEUt = -lEUt; + } + } + return result; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public void explodeMultiblock() { + this.mInventory[1] = null; + long explodevalue; + for (final MetaTileEntity tTileEntity : this.mInputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mInputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + this.getBaseMetaTileEntity() + .doExplosion(explodevalue); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + if (aBaseMetaTileEntity.isActive()) { + // Set casings active if we're warmed up. + this.turnCasingActive(this.mEfficiency == this.getMaxEfficiency(null)); + } else { + this.turnCasingActive(false); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // See if we're warmed up. + if (this.mEfficiency == this.getMaxEfficiency(null)) { + // Try output some Uranium-233 + if (MathUtils.randInt(1, 300) == 1) { + this.addOutput(MaterialsElements.getInstance().URANIUM233.getFluidStack(MathUtils.randInt(1, 10))); + } + } + return super.onRunningTick(aStack); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFuelRemaining", this.mFuelRemaining); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mFuelRemaining = aNBT.getInteger("mFuelRemaining"); + super.loadNBTData(aNBT); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java new file mode 100644 index 0000000000..b3f3f2b136 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEQuantumForceTransformer.java @@ -0,0 +1,939 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.ExoticEnergy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTOreDictUnificator.getAssociation; +import static gregtech.api.util.GTRecipeBuilder.BUCKETS; +import static gregtech.api.util.GTRecipeBuilder.INGOTS; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.ParallelHelper.addFluidsLong; +import static gregtech.api.util.ParallelHelper.addItemsLong; +import static gregtech.api.util.ParallelHelper.calculateChancedOutputMultiplier; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +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.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +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.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +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 gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +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.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.objects.ItemData; +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.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.ParallelHelper; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.material.MaterialsElements; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("SpellCheckingInspection") +public class MTEQuantumForceTransformer extends MTEExtendedPowerMultiBlockBase + implements ISurvivalConstructable { + + private int mCasing; + protected int mCraftingTier = 0; + protected int mFocusingTier = 0; + protected int mMaxParallel = 0; + private boolean mFluidMode = false, doFermium = false, doNeptunium = false; + private static final Fluid mNeptunium = MaterialsElements.getInstance().NEPTUNIUM.getPlasma(); + private static final Fluid mFermium = MaterialsElements.getInstance().FERMIUM.getPlasma(); + private static final String MAIN_PIECE = "main"; + private MTEHatchInput mNeptuniumHatch; + private MTEHatchInput mFermiumHatch; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + MAIN_PIECE, + new String[][] { // A - 142, B - 234, C - 177, D - 96, E - 224, H - 36, M - 21 + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " ", " ", " BAB ", " BBBBABBBB ", + " BAAAAAAAB ", " BABBABBAB ", " BA AB ", " A A ", " A A ", + " A A " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " ", " BAB ", " AAABBBAAA ", " BAAAAAAAAAB ", + " B B ", " A A ", " A A ", " ", " ", + " " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " BAB ", " AA AA ", " AA AA ", " BAA AAB ", + " B B ", " A A ", " A A ", " ", " ", + " " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " BAAAB ", " AA AA ", " AA AA ", "BAA AAB", + "B B", "A A", "A A", "A A", "A A", + "A A" }, + { " TTT ", " EEE ", " EEE ", " EEE ", " DDD ", + " EEE ", " DDD ", " EEE ", " EEE ", " EEE ", + " DDD ", " BAEEEAB ", " AA EEE AA ", " A EEE A ", "BA DDD AB", + "B EEE B", "B DDD B", " EEE ", " EEE ", " EEE ", + " Z~X " }, + { " TTTTT ", " ECCCE ", " ECCCE ", " ECCCE ", " D D ", + " ECCCE ", " D D ", " ECCCE ", " ECCCE ", " ECCCE ", + " D D ", " BAECCCEAB ", " A ECCCE A ", " A ECCCE A ", "BA D D AB", + "B ECCCE B", "B D D B", "B ECCCE B", " ECCCE ", " ECCCE ", + " HHHHH " }, + { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", + " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", + " D D ", " BAEC CEAB ", " B EC CE B ", "BB EC CE BB", "BA D D AB", + "A EC CE A", "A D D A", "A EC CE A", " EC CE ", " EC CE ", + " HHHHHHH " }, + { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", + " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", + " D D ", " AAEC CEAA ", " A EC CE A ", "AB EC CE BA", "AA D D AA", + "A EC CE A", "A D D A", " EC CE ", " EC CE ", " EC CE ", + " HHHHHHH " }, + { " TTTTTTT ", " ECCCCCE ", " EC CE ", " EC CE ", " D D ", + " EC CE ", " D D ", " EC CE ", " EC CE ", " EC CE ", + " D D ", " BAEC CEAB ", " B EC CE B ", "BB EC CE BB", "BA D D AB", + "A EC CE A", "A D D A", "A EC CE A", " EC CE ", " EC CE ", + " HHHHHHH " }, + { " TTTTT ", " ECCCE ", " ECCCE ", " ECCCE ", " D D ", + " ECCCE ", " D D ", " ECCCE ", " ECCCE ", " ECCCE ", + " D D ", " BAECCCEAB ", " A ECCCE A ", " A ECCCE A ", "BA D D AB", + "B ECCCE B", "B D D B", "B ECCCE B", " ECCCE ", " ECCCE ", + " HHHHH " }, + { " TTT ", " EEE ", " EEE ", " EEE ", " DDD ", + " EEE ", " DDD ", " EEE ", " EEE ", " EEE ", + " DDD ", " BAEEEAB ", " AA EEE AA ", " A EEE A ", "BA DDD AB", + "B EEE B", "B DDD B", " EEE ", " EEE ", " EEE ", + " HHH " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " BAAAB ", " AA AA ", " AA AA ", "BAA AAB", + "B B", "A A", "A A", "A A", "A A", + "A A" }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " BAB ", " AA AA ", " AA AA ", " BAA AAB ", + " B B ", " A A ", " A A ", " ", " ", + " " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " ", " BAB ", " AAABBBAAA ", " BAAAAAAAAAB ", + " B B ", " A A ", " A A ", " ", " ", + " " }, + { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " ", " ", " BAB ", " BBBBABBBB ", + " BBBAAABBB ", " ABBAAABBA ", " A BA AB A ", " A A ", " A A ", + " A A " }, }) + .addElement( + 'A', + withChannel( + "manipulator", + StructureUtility.ofBlocksTiered( + craftingTierConverter(), + getAllCraftingTiers(), + 0, + MTEQuantumForceTransformer::setCraftingTier, + MTEQuantumForceTransformer::getCraftingTier))) + .addElement( + 'B', + withChannel( + "shielding", + StructureUtility.ofBlocksTiered( + focusingTierConverter(), + getAllFocusingTiers(), + 0, + MTEQuantumForceTransformer::setFocusingTier, + MTEQuantumForceTransformer::getFocusingTier))) + .addElement('C', ofBlock(ModBlocks.blockCasings4Misc, 4)) + .addElement('D', ofBlock(ModBlocks.blockCasings2Misc, 12)) + .addElement('E', lazy(t -> ofBlock(t.getCasingBlock1(), t.getCasingMeta1()))) + .addElement( + 'H', + buildHatchAdder(MTEQuantumForceTransformer.class) + .atLeast(InputBus, InputHatch, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(4) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .addElement( + 'T', + buildHatchAdder(MTEQuantumForceTransformer.class).atLeast(OutputBus, OutputHatch, Maintenance) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(5) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .addElement( + 'Z', + buildHatchAdder(MTEQuantumForceTransformer.class).hatchClass(MTEHatchInput.class) + .adder(MTEQuantumForceTransformer::addNeptuniumHatch) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(5) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .addElement( + 'X', + buildHatchAdder(MTEQuantumForceTransformer.class).hatchClass(MTEHatchInput.class) + .adder(MTEQuantumForceTransformer::addFermiumHatch) + .casingIndex(TAE.getIndexFromPage(0, 10)) + .dot(5) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 12)))) + .build(); + + public MTEQuantumForceTransformer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEQuantumForceTransformer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEQuantumForceTransformer(this.mName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Quantum Force Transformer") + .addInfo("Controller Block for the Quantum Force Transformer") + .addInfo("Allows Complex chemical lines to be performed instantly in one step") + .addInfo("Every recipe requires a catalyst, each catalyst adds 1 parallel and lasts forever") + .addInfo("Accepts TecTech Energy and Laser Hatches") + .addInfo("All inputs go on the bottom, all outputs go on the top") + .addInfo("Put a circuit in the controller to specify the focused output") + .addInfo("Check NEI to see the order of outputs, and which circuit number you need.") + .addInfo("If separate input busses are enabled put the circuit in the circuit slot of the bus") + .addInfo("Uses FocusTier*4*sqrt(parallels) Neptunium Plasma if focusing") + .addInfo("Can use FocusTier*4*sqrt(parallels) Fermium Plasma for additional chance output") + .addInfo("Use a screwdriver to enable Fluid mode") + .addInfo( + "Fluid mode turns all possible outputs into their fluid variant, those which can't are left as they were.") + .addInfo("This multi gets improved when all casings of some types are upgraded") + .addInfo("Casing functions:") + .addInfo("Pulse Manipulators: Recipe Tier Allowed (check NEI for the tier of each recipe)") + .addInfo("Shielding Cores: Focusing Tier (equal to or higher than recipe tier to allow focus)") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(15, 21, 15, true) + .addController("Bottom Center") + .addCasingInfoMin("Bulk Production Frame", 80, false) + .addCasingInfoMin("Quantum Force Conductor", 177, false) + .addCasingInfoMin("Force Field Glass", 224, false) + .addCasingInfoMin("Pulse Manipulators", 236, true) + .addCasingInfoMin("Shielding Cores", 142, true) + .addInputBus(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) + .addInputHatch(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) + .addOutputHatch(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) + .addOutputBus(EnumChatFormatting.AQUA + "Top" + EnumChatFormatting.GRAY + " Layer", 5) + .addEnergyHatch(EnumChatFormatting.BLUE + "Bottom" + EnumChatFormatting.GRAY + " Layer", 4) + .addStructureInfo( + EnumChatFormatting.WHITE + "Neptunium Plasma Hatch: " + + EnumChatFormatting.GREEN + + "Left" + + EnumChatFormatting.GRAY + + " side of Controller") + .addStructureInfo( + EnumChatFormatting.WHITE + "Fermium Plasma Hatch: " + + EnumChatFormatting.DARK_GREEN + + "Right" + + EnumChatFormatting.GRAY + + " side of Controller") + .toolTipFinisher( + GTValues.AuthorBlueWeabo + EnumChatFormatting.RESET + + EnumChatFormatting.GREEN + + " + Steelux" + + EnumChatFormatting.RESET + + " - [GT++]"); + return tt; + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mCasing = 0; + this.mCraftingTier = 0; + this.mFocusingTier = 0; + if (!checkPiece(MAIN_PIECE, 7, 20, 4)) { + return false; + } + + if (mOutputBusses.isEmpty() || mOutputHatches.isEmpty()) { + return false; + } + + // Maintenance hatch not required but left for compatibility. + // Don't allow more than 1, no free casing spam! + if (mMaintenanceHatches.size() > 1) { + return false; + } + + return checkExoticAndNormalEnergyHatches(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(MAIN_PIECE, stackSize, hintsOnly, 7, 20, 4); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(MAIN_PIECE, stackSize, 7, 20, 4, elementBudget, env, false, true); + } + + public static List> getAllCraftingTiers() { + return new ArrayList<>() { + + { + add(Pair.of(ModBlocks.blockCasings5Misc, 7)); + add(Pair.of(ModBlocks.blockCasings5Misc, 8)); + add(Pair.of(ModBlocks.blockCasings5Misc, 9)); + add(Pair.of(ModBlocks.blockCasings5Misc, 10)); + } + }; + } + + public static List> getAllFocusingTiers() { + return new ArrayList<>() { + + { + add(Pair.of(ModBlocks.blockCasings5Misc, 11)); + add(Pair.of(ModBlocks.blockCasings5Misc, 12)); + add(Pair.of(ModBlocks.blockCasings5Misc, 13)); + add(Pair.of(ModBlocks.blockCasings5Misc, 14)); + } + }; + } + + public static ITierConverter craftingTierConverter() { + return (block, meta) -> { + if (block == null) { + return -1; + } else if (block == ModBlocks.blockCasings5Misc) { // Resonance Chambers + switch (meta) { + case 7 -> { + return 1; + } + case 8 -> { + return 2; + } + case 9 -> { + return 3; + } + case 10 -> { + return 4; + } + } + } + return -1; + }; + } + + public static ITierConverter focusingTierConverter() { + return (block, meta) -> { + if (block == null) { + return -1; + } else if (block == ModBlocks.blockCasings5Misc) { // Generation Coils + switch (meta) { + case 11 -> { + return 1; + } + case 12 -> { + return 2; + } + case 13 -> { + return 3; + } + case 14 -> { + return 4; + } + } + } + return -1; + }; + } + + private void setCraftingTier(int tier) { + mCraftingTier = tier; + } + + private void setFocusingTier(int tier) { + mFocusingTier = tier; + } + + private int getCraftingTier() { + return mCraftingTier; + } + + private int getFocusingTier() { + return mFocusingTier; + } + + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAQFTActive; + } + + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAQFT; + } + + protected int getCasingTextureId() { + return TAE.getIndexFromPage(0, 10); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.quantumForceTransformerRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + private int[] chances; + private FluidStack[] fluidModeItems; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (recipe.mSpecialValue > getCraftingTier()) { + return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue); + } + ItemStack catalyst = null; + for (ItemStack item : recipe.mInputs) { + if (ItemUtils.isCatalyst(item)) { + catalyst = item; + break; + } + } + + if (catalyst == null) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); + } + + maxParallel = 0; + for (ItemStack item : inputItems) { + if (ItemUtils.isCatalyst(item) && item.isItemEqual(catalyst)) { + maxParallel += item.stackSize; + } + } + + mMaxParallel = maxParallel; + doFermium = false; + doNeptunium = false; + + if (recipe.mSpecialValue <= getFocusingTier()) { + if (drain(mFermiumHatch, new FluidStack(mFermium, 1), false)) { + doFermium = true; + } + if (drain(mNeptuniumHatch, new FluidStack(mNeptunium, 1), false)) { + doNeptunium = true; + } + } + + chances = getOutputChances(recipe, doNeptunium ? findProgrammedCircuitNumber() : -1); + + // Handle Fluid Mode. Add fluid that item can be turned into to fluidModeItems. + // null if Fluid Mode is disabled or item cannot be turned into fluid. + fluidModeItems = new FluidStack[recipe.mOutputs.length]; + if (mFluidMode) { + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null) continue; + ItemData data = getAssociation(item); + Materials mat = data == null ? null : data.mMaterial.mMaterial; + if (mat != null) { + if (mat.mStandardMoltenFluid != null) { + fluidModeItems[i] = mat.getMolten(INGOTS); + } else if (mat.mFluid != null) { + fluidModeItems[i] = mat.getFluid(BUCKETS); + } + } + } + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + public ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) { + return super.createParallelHelper(recipe).setCustomItemOutputCalculation(parallel -> { + ArrayList items = new ArrayList<>(); + + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null || fluidModeItems[i] != null) continue; + ItemStack itemToAdd = item.copy(); + double outputMultiplier = calculateChancedOutputMultiplier(chances[i], parallel); + long itemAmount = (long) (item.stackSize * outputMultiplier); + addItemsLong(items, itemToAdd, itemAmount); + } + + return items.toArray(new ItemStack[0]); + }) + .setCustomFluidOutputCalculation(parallel -> { + ArrayList fluids = new ArrayList<>(); + + if (mFluidMode) { + for (int i = 0; i < recipe.mOutputs.length; i++) { + FluidStack fluid = fluidModeItems[i]; + if (fluid == null) continue; + FluidStack fluidToAdd = fluid.copy(); + double outputMultiplier = calculateChancedOutputMultiplier(chances[i], parallel); + int itemAmount = recipe.mOutputs[i].stackSize; + long fluidAmount = (long) (fluidToAdd.amount * outputMultiplier * itemAmount); + 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(); + double outputMultiplier = calculateChancedOutputMultiplier( + chances[i + recipe.mOutputs.length], + parallel); + long fluidAmount = (long) (fluidToAdd.amount * outputMultiplier); + addFluidsLong(fluids, fluidToAdd, fluidAmount); + } + + return fluids.toArray(new FluidStack[0]); + }); + } + + private int findProgrammedCircuitNumber() { + if (isInputSeparationEnabled()) { + for (ItemStack stack : inputItems) { + if (GTUtility.isAnyIntegratedCircuit(stack)) { + return stack.getItemDamage() - 1; + } + } + return -1; + } else { + final ItemStack controllerStack = getControllerSlot(); + return GTUtility.isAnyIntegratedCircuit(controllerStack) ? controllerStack.getItemDamage() - 1 : -1; + } + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(getAverageInputVoltage()); + logic.setAvailableAmperage(getMaxInputAmps()); + } + + private byte runningTick = 0; + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (!super.onRunningTick(aStack)) { + return false; + } + + if (runningTick % 20 == 0) { + int amount = (int) (getFocusingTier() * 4 + * Math.sqrt(Math.min(mMaxParallel, processingLogic.getCurrentParallels()))); + if (doFermium) { + FluidStack fermiumToConsume = new FluidStack(mFermium, amount); + if (!drain(mFermiumHatch, fermiumToConsume, true)) { + doFermium = false; + stopMachine(ShutDownReasonRegistry.outOfFluid(fermiumToConsume)); + return false; + } + } + + if (doNeptunium) { + FluidStack neptuniumToConsume = new FluidStack(mNeptunium, amount); + if (!drain(mNeptuniumHatch, neptuniumToConsume, true)) { + doNeptunium = false; + stopMachine(ShutDownReasonRegistry.outOfFluid(neptuniumToConsume)); + return false; + } + } + + runningTick = 1; + } else { + runningTick++; + } + + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // TODO: Look for proper fix + // Updates every 30 sec + if (mUpdate <= -550) mUpdate = 50; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public static int getBaseOutputChance(GTRecipe tRecipe) { + int aOutputsAmount = tRecipe.mOutputs.length + tRecipe.mFluidOutputs.length; + return 10000 / aOutputsAmount; + } + + private int[] getOutputChances(GTRecipe tRecipe, int aChanceIncreased) { + int difference = getFocusingTier() - tRecipe.mSpecialValue; + int aOutputsAmount = tRecipe.mOutputs.length + tRecipe.mFluidOutputs.length; + int aChancePerOutput = 10000 / aOutputsAmount; + int[] tChances = new int[aOutputsAmount]; + Arrays.fill(tChances, aChancePerOutput); + + switch (difference) { + case 0 -> { + for (int i = 0; i < tChances.length; i++) { + if (doNeptunium) { + if (i == aChanceIncreased) { + tChances[i] += aChancePerOutput / 2 * (aOutputsAmount - 1); + } else { + tChances[i] /= 2; + } + } + + if (doFermium) { + tChances[i] += (10000 - tChances[i]) / 4; + } + } + } + case 1 -> { + for (int i = 0; i < tChances.length; i++) { + if (doNeptunium) { + if (i == aChanceIncreased) { + tChances[i] += aChancePerOutput * 3 / 4 * (aOutputsAmount - 1); + } else { + tChances[i] /= 4; + } + } + + if (doFermium) { + tChances[i] += (10000 - tChances[i]) / 3; + } + } + } + case 2, 3 -> { + for (int i = 0; i < tChances.length; i++) { + if (doNeptunium) { + if (i == aChanceIncreased) { + tChances[i] = 10000; + } else { + tChances[i] = 0; + } + } + + if (doFermium) { + tChances[i] += (10000 - tChances[i]) / 2; + } + } + } + } + return tChances; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mFluidMode = !mFluidMode; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("miscutils.machines.QFTFluidMode") + " " + mFluidMode); + } + + public boolean addNeptuniumHatch(IGregTechTileEntity aTileEntity, short aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = null; + mNeptuniumHatch = (MTEHatchInput) aMetaTileEntity; + return true; + } + return false; + } + + public boolean addFermiumHatch(IGregTechTileEntity aTileEntity, short aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = null; + mFermiumHatch = (MTEHatchInput) aMetaTileEntity; + return true; + } + return false; + } + + public Block getCasingBlock1() { + return ModBlocks.blockCasings5Misc; + } + + public byte getCasingMeta1() { + return 15; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mFluidMode", mFluidMode); + aNBT.setBoolean("doFermium", doFermium); + aNBT.setBoolean("doNeptunium", doNeptunium); + aNBT.setInteger("mMaxParallel", mMaxParallel); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("mSeparateInputBusses"); + } + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + batchMode = aNBT.getBoolean("mBatchMode"); + } + mFluidMode = aNBT.getBoolean("mFluidMode"); + doFermium = aNBT.getBoolean("doFermium"); + doNeptunium = aNBT.getBoolean("doNeptunium"); + mMaxParallel = aNBT.getInteger("mMaxParallel"); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { getCasingTexture(), TextureFactory.builder() + .addIcon(getActiveOverlay()) + .extFacing() + .build() }; + return new ITexture[] { getCasingTexture(), TextureFactory.builder() + .addIcon(getInactiveOverlay()) + .extFacing() + .build() }; + } + return new ITexture[] { getCasingTexture() }; + } + + private ITexture getCasingTexture() { + return Textures.BlockIcons.getCasingTextureForId(getCasingTextureId()); + } + + @SideOnly(Side.CLIENT) + private void renderForceField(double x, double y, double z, int side, double minU, double maxU, double minV, + double maxV) { + // spotless:off + Tessellator tes = Tessellator.instance; + switch (side) { + case 0 -> { + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); + tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); + tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); + tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + } + case 1 -> { + tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); + tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); + tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); + tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); + } + case 2 -> { + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); + tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); + tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); + tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + } + case 3 -> { + tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); + tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); + tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); + tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); + } + case 4 -> { + tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); + tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); + tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); + tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); + } + case 5 -> { + tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); + tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); + } + case 6 -> { + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); + tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); + tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + } + case 7 -> { + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); + tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + } + } + } + + @SideOnly(Side.CLIENT) + @Override + public boolean renderInWorld(IBlockAccess aWorld, int x, int y, int z, Block block, RenderBlocks renderer) { + Tessellator tes = Tessellator.instance; + IIcon forceField = TexturesGtBlock.ForceField.getIcon(); + if (getBaseMetaTileEntity().isActive()) { + double minU = forceField.getMinU(); + double maxU = forceField.getMaxU(); + double minV = forceField.getMinV(); + double maxV = forceField.getMaxV(); + double xBaseOffset = 3 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zBaseOffset = 3 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + tes.setColorOpaque_F(1f, 1f, 1f); + tes.setBrightness(15728880); + //Center O: 0, 0 1 ------- 8 + //Corner 1: 7, -2 / \ + //Corner 2: 3, -6 2 / \ 7 + //Corner 3: -2, -6 | | + //Corner 4: -6, -2 | O | + //Corner 5: -6, 3 | | + //Corner 6: -2, 7 3 \ / 6 + //Corner 7: 3, 7 \ / + //Corner 8: 7, 3 4 ------- 5 + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 0, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 1, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 2, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 3, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 4, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 5, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 6, minU, maxU, minV, maxV); + renderForceField(x + xBaseOffset + 0.5, y, z + zBaseOffset + 0.5, 7, minU, maxU, minV, maxV); + } + // Needs to be false to render the controller + return false; + //spotless:on + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java new file mode 100644 index 0000000000..2160f43546 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java @@ -0,0 +1,218 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.filterByMTETier; + +import net.minecraft.item.ItemStack; + +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 gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public class MTERefinery extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTERefinery(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTERefinery(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Fuel Refinery"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fission Fuel Processing Unit") + .addInfo("Refines fluorides and Uranium into nuclear fuel for the LFTR") + .addInfo("LFTR Fuel 2 and Fuel 3 have alternative, much more efficient recipes") + .addInfo("However, they require fission breeding outputs from the LFTR itself") + .addInfo("Only one Energy Hatch is allowed per Processing Unit") + .addInfo("All recipe times in this multi are very long, watch out!") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Bottom Center") + .addCasingInfoMin("Hastelloy-X Structural Block", 7, false) + .addCasingInfoMin("Incoloy-DS Fluid Containment Block", 5, false) + .addCasingInfoMin("Zeron-100 Reactor Shielding", 4, false) + .addCasingInfoMin("Hastelloy-N Sealant Blocks", 17, false) + .addInputHatch("Base platform", 1) + .addOutputHatch("Base platform", 1) + .addMufflerHatch("Base platform", 1) + .addMaintenanceHatch("Base platform", 1) + .addEnergyHatch("Base platform", 1) + .addStructureInfo("Muffler's Tier must be IV+") + .addStructureInfo("2-4x Input Hatches, 1-2x Output Hatches") + .addStructureInfo("1x Muffler, 1x Maintenance Hatch, 1x Energy Hatch") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(18); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.fissionFuelProcessingRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchMuffler && ((MTEHatchMuffler) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { " ", " N ", " " }, { " N ", "NIN", " N " }, { " N ", "NIN", " N " }, + { " N ", "NIN", " N " }, { " Z ", "ZIZ", " Z " }, { " N ", "NIN", " N " }, + { "XXX", "XXX", "XXX" }, { "X~X", "XXX", "XXX" }, })) + .addElement( + 'X', + ofChain( + buildHatchAdder(MTERefinery.class) + .atLeast(Energy, Maintenance, OutputHatch, OutputBus, InputHatch) + .casingIndex(TAE.GTPP_INDEX(18)) + .dot(1) + .build(), + buildHatchAdder(MTERefinery.class).atLeast(Muffler) + .adder(MTERefinery::addMufflerToMachineList) + .hatchItemFilterAnd(t -> filterByMTETier(6, Integer.MAX_VALUE)) + .casingIndex(TAE.GTPP_INDEX(18)) + .dot(1) + .build(), + onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 2)))) + .addElement('I', ofBlock(ModBlocks.blockCasings2Misc, 3)) + .addElement('N', ofBlock(ModBlocks.blockCasings2Misc, 1)) + .addElement('Z', ofBlock(ModBlocks.blockCasingsMisc, 13)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 7, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 7, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { + if (this.mInputHatches.size() >= 2 && this.mInputHatches.size() <= 4 + && this.mOutputHatches.size() >= 1 + && this.mOutputHatches.size() <= 2 + && this.mMufflerHatches.size() == 1 + && this.mMaintenanceHatches.size() == 1 + && this.mEnergyHatches.size() == 1) { + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); + return true; + } + } + return false; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiRefinery; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTERefinery(this.mName); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java new file mode 100644 index 0000000000..085cb1b784 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java @@ -0,0 +1,672 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.material.MaterialMisc; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.MTESolarHeater; + +public class MTESolarTower extends GTPPMultiBlockBase implements ISurvivalConstructable { + + // 862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 9); + private int mHeatLevel = 0; + private int mCasing1; + private int mCasing2; + private int mCasing3; + private int mCasing4; + + public ArrayList mSolarHeaters = new ArrayList<>(); + + public MTESolarTower(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTESolarTower(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTESolarTower(this.mName); + } + + @Override + public String getMachineType() { + return "Solar Tower"; + } + + @Override + protected final MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Contributing Green Energy towards the future") + .addInfo("Surround with rings of Solar Reflectors") + .addInfo("The Reflectors increase the internal heat value of the Tower (see below for formula)") + .addInfo("Each Reflector ring increases tier, the first ring is required for the Tower to work") + .addInfo("Input: " + MaterialMisc.SOLAR_SALT_COLD.getLocalizedName()) + .addInfo("Output: " + MaterialMisc.SOLAR_SALT_HOT.getLocalizedName()) + .addInfo("Every cycle (10 seconds), heat increases and all the Cold Solar Salt is heated") + .addInfo("Converting Cold to Hot Solar Salt reduces heat, equal to the amount converted") + .addInfo("This conversion only happens if heat >= 30000 and controller efficiency = 100%") + .addInfo("If there's more Cold Salt than heat, all the heat is used up and returns to 0") + .addInfo("The heat increase is most efficient at exactly half of maximum heat") + .addInfo("Minimum efficiency at 0 or 100000 heat, maximum efficiency at 50000") + .addInfo("Heat Efficiency formula: ( 7000 - [|currentHeat - 50000| ^ 0.8]) / 7000") + .addInfo("Heat gain per cycle: numberHeaters * heatEfficiency * (10 + bonus)") + .addInfo("Bonus: 1 ring = +1, 2 rings = +2, 3 rings = +4, 4 rings = +8, 5 rings = +16") + .addInfo("Total number of reflectors based on how many rings are built:") + .addInfo("1 ring = 36, 2 rings = 88, 3 rings = 156, 4 rings = 240, 5 rings = 340") + .addSeparator() + .beginVariableStructureBlock(15, 31, 28, 28, 15, 31, false) + .addController("Top Middle") + .addCasingInfoMin("Structural Solar Casing", 229, false) + .addCasingInfoMin("Thermally Insulated Casing", 60, false) + .addCasingInfoMin("Salt Containment Casing", 66, false) + .addCasingInfoMin("Thermal Containment Casing", 60, false) + .addInputHatch("Any 2 dot hint(min 1)", 2) + .addOutputHatch("Any 2 dot hint(min 1)", 2) + .addMaintenanceHatch("Any 2 dot hint", 2) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + private static final String STRUCTURE_PIECE_BASE = "base"; + private static final String STRUCTURE_PIECE_TOWER = "tower"; + private static final String STRUCTURE_PIECE_TOP = "top"; + + private static final String[] STRUCTURE_PIECE_SOLAR_HEATER_RING = { "ring1", "ring2", "ring3", "ring4", "ring5" }; + private static final String SOLAR_HEATER_RING_1 = STRUCTURE_PIECE_SOLAR_HEATER_RING[0]; + private static final String SOLAR_HEATER_RING_2 = STRUCTURE_PIECE_SOLAR_HEATER_RING[1]; + private static final String SOLAR_HEATER_RING_3 = STRUCTURE_PIECE_SOLAR_HEATER_RING[2]; + private static final String SOLAR_HEATER_RING_4 = STRUCTURE_PIECE_SOLAR_HEATER_RING[3]; + private static final String SOLAR_HEATER_RING_5 = STRUCTURE_PIECE_SOLAR_HEATER_RING[4]; + + private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { + + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + + // s = salt + // c = thermal containment + // i = thermal insulated + // t = solar structural + // h = hatch + // g = solar heater + + .addShape( + STRUCTURE_PIECE_TOP, + (new String[][] { { " ", " ", " ~ ", " ", " " }, + { " ", " s ", " sss ", " s ", " " }, + { " c ", " ccc ", "ccscc", " ccc ", " c " }, + { " c ", " ccc ", "ccscc", " ccc ", " c " }, + { " c ", " ccc ", "ccscc", " ccc ", " c " }, + { " c ", " ccc ", "ccscc", " ccc ", " c " }, + { " c ", " ccc ", "ccscc", " ccc ", " c " }, })) + .addShape( + STRUCTURE_PIECE_TOWER, + (new String[][] { { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, + { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, + { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, + { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, + { " i ", "isi", " i " }, { " i ", "isi", " i " }, { " i ", "isi", " i " }, })) + .addShape( + STRUCTURE_PIECE_BASE, + (new String[][] { + { " ", " ", " t ", " ttt ", " ttstt ", " ttssstt ", + " ttstt ", " ttt ", " t ", " ", " " }, + { " ", " ", " t ", " ttt ", " tssst ", " ttssstt ", + " tssst ", " ttt ", " t ", " ", " " }, + { " ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", + " ttssstt ", " ttttt ", " ttt ", " t ", " " }, + { " ", " t ", " ttt ", " ttttt ", " ttssstt ", " tttsssttt ", + " ttssstt ", " ttttt ", " ttt ", " t ", " " }, + { " hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "htttsssttth", "htttsssttth", + "htttsssttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh " }, + { " hhh ", " ttttt ", " ttttttt ", " ttttttttt ", "httttttttth", "httttttttth", + "httttttttth", " ttttttttt ", " ttttttt ", " ttttt ", " hhh " }, })) + .addShape( + SOLAR_HEATER_RING_1, + (new String[][] { { " ggggg ", " g g ", " g g ", " g g ", + " g g ", "g g", "g g", "g g", "g g", + "g g", " g g ", " g g ", " g g ", " g g ", + " ggggg ", } })) + .addShape( + SOLAR_HEATER_RING_2, + (new String[][] { + { " ggggggggg ", " g g ", " g g ", " g g ", + " g g ", "g g", "g g", "g g", + "g g", "g g", "g g", "g g", + "g g", "g g", " g g ", " g g ", + " g g ", " g g ", " ggggggggg ", } })) + .addShape( + SOLAR_HEATER_RING_3, + (new String[][] { { " ggggggggggggg ", " g g ", " g g ", + " g g ", " g g ", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + " g g ", " g g ", " g g ", + " g g ", " ggggggggggggg ", } })) + .addShape( + SOLAR_HEATER_RING_4, + (new String[][] { { " ggggggggggggggggg ", " g g ", + " g g ", " g g ", " g g ", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", "g g", + "g g", "g g", " g g ", + " g g ", " g g ", " g g ", + " ggggggggggggggggg ", } })) + .addShape( + SOLAR_HEATER_RING_5, + (new String[][] { { " ggggggggggggggggggggg ", " g g ", + " g g ", " g g ", + " g g ", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + "g g", "g g", + " g g ", " g g ", + " g g ", " g g ", + " ggggggggggggggggggggg ", } })) + .addElement( + 'g', + lazy( + t -> buildHatchAdder(MTESolarTower.class).hatchClass(MTESolarHeater.class) + .adder(MTESolarTower::addSolarHeater) + // Use a positive casing index to make adder builder happy + .casingIndex(1) + .dot(1) + .continueIfSuccess() + .build())) + .addElement( + 't', + lazy(t -> onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta())))) + .addElement( + 'i', + lazy(t -> onElementPass(x -> ++x.mCasing2, ofBlock(t.getCasingBlock(), t.getCasingMeta2())))) + .addElement( + 's', + lazy(t -> onElementPass(x -> ++x.mCasing3, ofBlock(t.getCasingBlock(), t.getCasingMeta3())))) + .addElement( + 'c', + lazy(t -> onElementPass(x -> ++x.mCasing4, ofBlock(t.getCasingBlock2(), t.getCasingMeta4())))) + .addElement( + 'h', + lazy( + t -> buildHatchAdder(MTESolarTower.class).atLeast(InputHatch, OutputHatch, Maintenance) + .casingIndex(t.getCasingTextureIndex()) + .dot(2) + .buildAndChain( + onElementPass(x -> ++x.mCasing1, ofBlock(t.getCasingBlock(), t.getCasingMeta()))))) + .build(); + } + }; + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + resetSolarHeaters(); + this.mMaintenanceHatches.clear(); + this.mInputHatches.clear(); + this.mOutputHatches.clear(); + mCasing1 = 0; + mCasing2 = 0; + mCasing3 = 0; + mCasing4 = 0; + + boolean aStructureTop = checkPiece(STRUCTURE_PIECE_TOP, 2, 2, 0); + log("Top Check: " + aStructureTop); + boolean aStructureTower = checkPiece(STRUCTURE_PIECE_TOWER, 1, 1, -7); + log("Tower Check: " + aStructureTower); + boolean aStructureBase = checkPiece(STRUCTURE_PIECE_BASE, 5, 5, -22); + log("Base Check: " + aStructureBase); + boolean aCasingCount1 = mCasing1 >= 229; + boolean aCasingCount2 = mCasing2 == 60; + boolean aCasingCount3 = mCasing3 == 66; + boolean aCasingCount4 = mCasing4 == 60; + boolean aAllStructure = aStructureTop && aStructureTower && aStructureBase; + boolean aAllCasings = aCasingCount1 && aCasingCount2 && aCasingCount3 && aCasingCount4; + if (!aAllCasings || !aAllStructure + || mMaintenanceHatches.size() != 1 + || mInputHatches.size() < 1 + || mOutputHatches.size() < 1) { + log( + "Bad Hatches - Solar Heaters: " + mSolarHeaters.size() + + ", Maint: " + + mMaintenanceHatches.size() + + ", Input Hatches: " + + mInputHatches.size() + + ", Output Hatches: " + + mOutputHatches.size() + + ", Top: " + + aStructureTop + + ", Tower: " + + aStructureTower + + ", Base: " + + aStructureBase + + ", Casing Count: " + + aCasingCount1 + + " | Found: " + + mCasing1 + + ", Casing Count: " + + aCasingCount2 + + " | Found: " + + mCasing2 + + ", Casing Count: " + + aCasingCount3 + + " | Found: " + + mCasing3 + + ", Casing Count: " + + aCasingCount4 + + " | Found: " + + mCasing4); + return false; + } + log( + "Built " + this.getLocalName() + + " with " + + mCasing1 + + " Structural Solar casings, " + + mCasing2 + + " Thermally Insulated casings, " + + mCasing3 + + " Salt Containment casings, " + + mCasing4 + + " Thermal Containment casings."); + return aAllCasings && aAllStructure; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + // Tower + buildPiece(STRUCTURE_PIECE_TOP, stackSize, hintsOnly, 2, 2, 0); + buildPiece(STRUCTURE_PIECE_TOWER, stackSize, hintsOnly, 1, 1, -7); + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 5, 5, -22); + + // Solar Heaters + if (stackSize.stackSize >= 1) { + buildPiece(SOLAR_HEATER_RING_1, stackSize, hintsOnly, 7, 7, -27); + if (stackSize.stackSize >= 2) { + buildPiece(SOLAR_HEATER_RING_2, stackSize, hintsOnly, 9, 9, -27); + if (stackSize.stackSize >= 3) { + buildPiece(SOLAR_HEATER_RING_3, stackSize, hintsOnly, 11, 11, -27); + if (stackSize.stackSize >= 4) { + buildPiece(SOLAR_HEATER_RING_4, stackSize, hintsOnly, 13, 13, -27); + if (stackSize.stackSize >= 5) { + buildPiece(SOLAR_HEATER_RING_5, stackSize, hintsOnly, 15, 15, -27); + } + } + } + } + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + int built; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); + // Tower + built = survivialBuildPiece(STRUCTURE_PIECE_TOP, stackSize, 2, 2, 0, realBudget, env, false, true); + if (built >= 0) return built; + built = survivialBuildPiece(STRUCTURE_PIECE_TOWER, stackSize, 1, 1, -7, realBudget, env, false, true); + if (built >= 0) return built; + built = survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 5, 5, -22, realBudget, env, false, true); + if (built >= 0) return built; + + // Solar Heaters + if (stackSize.stackSize < 1) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_1, stackSize, 7, 7, -27, realBudget, env, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 2) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_2, stackSize, 9, 9, -27, realBudget, env, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 3) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_3, stackSize, 11, 11, -27, realBudget, env, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 4) return -1; + built = survivialBuildPiece(SOLAR_HEATER_RING_4, stackSize, 13, 13, -27, realBudget, env, false, true); + if (built >= 0) return built; + if (stackSize.stackSize < 5) return -1; + return survivialBuildPiece(SOLAR_HEATER_RING_5, stackSize, 15, 15, -27, realBudget, env, false, true); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION.get(getClass()); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCDSolarTowerActive) + .extFacing() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCDSolarTower) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)) }; + } + + @Override + public RecipeMap getRecipeMap() { + // Only for visual + return GTPPRecipeMaps.solarTowerRecipes; + } + + private int getHeaterTier() { + int aSolarHeaterCounter = this.mSolarHeaters.size(); + if (aSolarHeaterCounter > 0) { + if (aSolarHeaterCounter == 36) { + return 1; + } else if (aSolarHeaterCounter == 88) { + return 2; + } else if (aSolarHeaterCounter == 156) { + return 4; + } else if (aSolarHeaterCounter == 240) { + return 8; + } else if (aSolarHeaterCounter == 340) { + return 16; + } + } + return 0; + } + + private int getHeaterCountForTier(int aTier) { + return switch (aTier) { + case 1 -> 36; + case 2 -> 88; + case 4 -> 156; + case 8 -> 240; + case 16 -> 340; + default -> 0; + }; + } + + public boolean getConnectedSolarReflectors() { + + resetSolarHeaters(); + int aRing = 1; + + if (this.mSolarHeaters.size() < 36) { + // 15x15 + boolean aRing1 = checkPiece(SOLAR_HEATER_RING_1, 7, 7, -27); + if (aRing1) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 88) { + // 17x17 + boolean aRing2 = checkPiece(SOLAR_HEATER_RING_2, 9, 9, -27); + if (aRing2) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 156) { + // 19x19 + boolean aRing3 = checkPiece(SOLAR_HEATER_RING_3, 11, 11, -27); + if (aRing3) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 240) { + // 21x21 + boolean aRing4 = checkPiece(SOLAR_HEATER_RING_4, 13, 13, -27); + if (aRing4) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + if (this.mSolarHeaters.size() < 340) { + // 23x23 + boolean aRing5 = checkPiece(SOLAR_HEATER_RING_5, 15, 15, -27); + if (aRing5) { + // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); + } + } + return mSolarHeaters.size() > 0; + } + + private boolean addSolarHeater(IGregTechTileEntity aTileEntity, int a) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTESolarHeater mTile) { + if (!mTile.hasSolarTower() && mTile.canSeeSky()) { + // Logger.INFO("Found Solar Reflector, Injecting Data."); + mTile.setSolarTower(this); + return this.mSolarHeaters.add(mTile); + } + } + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d == ForgeDirection.UP; + } + + private Fluid mColdSalt = null; + private Fluid mHotSalt = null; + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + this.mEfficiencyIncrease = 100; + this.mMaxProgresstime = 200; + + if (this.mSolarHeaters.isEmpty() || this.mSolarHeaters.size() < 340 + || this.getTotalRuntimeInTicks() % 200 == 0) { + getConnectedSolarReflectors(); + } + + int aTier = getHeaterTier(); + int aHeaters = getHeaterCountForTier(aTier); + + // Original formula was (-Math.pow(this.mHeatLevel - 50000, 0.8) + 7000) / 7000 + // However, negative numbers to the power of a non-integer result in NaN, by default + // Max efficiency is 1, at mHeatLevel = 50000, and it lowers at the same rate if going above or below this heat + // Min efficiency is 0.179, at mHeatLevel = 0 or 100000 + double aEfficiency = (-Math.pow(Math.abs(this.mHeatLevel - 50000), 0.8) + 7000) / 7000; + + World w = this.getBaseMetaTileEntity() + .getWorld(); + + // Manage Heat every 10s + // Add Heat First, if sources available and it's daytime, heat gain is halved if raining + if (w != null) { + if (aHeaters > 0 && w.isDaytime()) { + if (w.isRaining() && this.getBaseMetaTileEntity() + .getBiome().rainfall > 0.0F) { + this.mHeatLevel += GTUtility.safeInt((long) ((aHeaters / 2) * aEfficiency * (10 + aTier))); + } else { + this.mHeatLevel += GTUtility.safeInt((long) (aHeaters * aEfficiency * (10 + aTier))); + } + } + + // Remove Heat, based on time of day + if (mHeatLevel > 0) { + if (mHeatLevel > 100000) { + this.mHeatLevel = 100000; + } else { + this.mHeatLevel -= 10; + } + } + } + + if (this.mEfficiency == this.getMaxEfficiency(null) && this.mHeatLevel >= 30000) { + if (mColdSalt == null) { + mColdSalt = MaterialMisc.SOLAR_SALT_COLD.getFluid(); + } + if (mHotSalt == null) { + mHotSalt = MaterialMisc.SOLAR_SALT_HOT.getFluid(); + } + ArrayList aFluids = this.getStoredFluids(); + for (FluidStack aFluid : aFluids) { + if (aFluid.getFluid() + .equals(mColdSalt)) { + int aFluidAmount = Math.min(aFluid.amount, this.mHeatLevel); + + this.mHeatLevel -= aFluidAmount; + this.depleteInput(FluidUtils.getFluidStack(mColdSalt, aFluidAmount)); + this.addOutput(FluidUtils.getFluidStack(mHotSalt, aFluidAmount)); + this.mHeatLevel = Math.max(this.mHeatLevel, 0); + + break; + } + } + } + + return CheckRecipeResultRegistry.GENERATING; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 6; + } + + public byte getCasingMeta2() { + return 8; + } + + public byte getCasingMeta3() { + return 7; + } + + public byte getCasingMeta4() { + return 11; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {} + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mHeatLevel", mHeatLevel); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mHeatLevel = aNBT.getInteger("mHeatLevel"); + } + + @Override + public void onRemoval() { + resetSolarHeaters(); + super.onRemoval(); + } + + private void resetSolarHeaters() { + for (MTESolarHeater aTile : this.mSolarHeaters) { + aTile.clearSolarTower(); + } + this.mSolarHeaters.clear(); + } + + @Override + public String[] getExtraInfoData() { + return new String[] { "Internal Heat Level: " + this.mHeatLevel, + "Connected Solar Reflectors: " + this.mSolarHeaters.size() }; + } + + @Override + public boolean doesBindPlayerInventory() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEThermalBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEThermalBoiler.java new file mode 100644 index 0000000000..8889cbd501 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEThermalBoiler.java @@ -0,0 +1,352 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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 gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.ParallelHelper; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEThermalBoiler extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private static final int lavaFilterResilience = 30; // Damage lava filter with 1/n probability every operation. + private int dryHeatCounter = 0; // Counts up to dryHeatMaximum to check for explosion conditions. + private static final int dryHeatMaximum = 10; // 10 consecutive operations without water = BOOM + + private static final Item itemLavaFilter = ItemList.Component_LavaFilter.getItem(); + private static final Item itemObsidian = Item.getItemFromBlock(Blocks.obsidian); + private static final Fluid fluidWater = FluidRegistry.WATER; + private static final Fluid fluidDistilledWater = FluidUtils.getDistilledWater(1) + .getFluid(); + private static final Fluid fluidSteam = FluidUtils.getSteam(1) + .getFluid(); + private static final Fluid fluidSHSteam = FluidUtils.getSuperHeatedSteam(1) + .getFluid(); + + public MTEThermalBoiler(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEThermalBoiler(String mName) { + super(mName); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEThermalBoiler(this.mName); + } + + @Override + public String getMachineType() { + return "Boiler"; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (aStack != null && aStack.getItem() == itemLavaFilter) ? 1 : 0; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.thermalBoilerRecipes; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + // Only test against the first fluid input in the recipe. + // We still want to run if we lack water (and subsequently explode). + @NotNull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + if (lastRecipe != null && depleteInput(lastRecipe.mFluidInputs[0], true)) { + return Stream.of(lastRecipe); + } + if (map == null) { + return Stream.empty(); + } + return map.getAllRecipes() + .stream() + .filter(recipe -> depleteInput(recipe.mFluidInputs[0], true)); + } + + @NotNull + @Override + protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) { + GTRecipe adjustedRecipe = recipe.copy(); + + // Hack the recipe logic to not consume water, so that we can explode. + for (FluidStack inputFluid : adjustedRecipe.mFluidInputs) { + if (inputFluid != null + && (inputFluid.getFluid() == fluidWater || inputFluid.getFluid() == fluidDistilledWater)) { + inputFluid.amount = 0; + } + } + + // If we don't have a lava filter, remove non-obsidian outputs + // so that output space for them is not required if void protection is on. + if (!findLavaFilter()) { + for (ItemStack outputItem : adjustedRecipe.mOutputs) { + if (outputItem != null && outputItem.getItem() != itemObsidian) { + outputItem.stackSize = 0; + } + } + } + return super.createParallelHelper(adjustedRecipe); + } + }; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + // super.checkProcessing() instantly sets efficiency to maximum, override this. + int efficiency = mEfficiency; + CheckRecipeResult result = super.checkProcessing(); + if (result.wasSuccessful()) { + mEfficiency = efficiency; + mEfficiencyIncrease = mMaxProgresstime * getEfficiencyIncrease(); + + // Adjust steam output based on efficiency. + if (mOutputFluids != null) { + for (FluidStack outputFluid : mOutputFluids) { + if (outputFluid != null + && (outputFluid.getFluid() == fluidSteam || outputFluid.getFluid() == fluidSHSteam)) { + + // Purely for display reasons, we don't actually make any EU. + if (outputFluid.getFluid() == fluidSteam) { + lEUt = outputFluid.amount / mMaxProgresstime / 2; + } else { + lEUt = outputFluid.amount / mMaxProgresstime; + } + + // Adjust steam output based on efficiency. + // TODO: This is not reflected in the GUI while the player has it open?? + if (mEfficiency < getMaxEfficiency(null)) { + outputFluid.amount = Math + .max(1, (outputFluid.amount * mEfficiency) / getMaxEfficiency(null)); + } + + // Consume water to run recipe. + if (!useWater(outputFluid.amount)) { + outputFluid.amount = 0; + lEUt = 0; + } + } + } + } + + // Remove non-obsidian outputs if we can't damage lava filter. + if (mOutputItems != null && mOutputItems.length > 0) { + if (!damageLavaFilter()) { + for (ItemStack outputItem : mOutputItems) { + if (outputItem != null && outputItem.getItem() != itemObsidian) { + outputItem.stackSize = 0; + } + } + } + } + } + return result; + } + + private boolean findLavaFilter() { + if (getControllerSlot() == null) { + for (var bus : mInputBusses) { + for (ItemStack stack : bus.mInventory) { + if (stack != null && stack.getItem() == itemLavaFilter) { + setGUIItemStack(stack); + return true; + } + } + } + return false; + } else { + return getControllerSlot().getItem() == itemLavaFilter; + } + } + + private boolean damageLavaFilter() { + if (!findLavaFilter()) return false; + if (getBaseMetaTileEntity().getRandomNumber(lavaFilterResilience) > 0) return true; + + ItemStack filter = getControllerSlot(); + if (filter.attemptDamageItem(1, getBaseMetaTileEntity().getWorld().rand)) { + mInventory[1] = null; + } + return true; + } + + private boolean useWater(int steamAmount) { + // Round up to not dupe decimal amounts of water. + int waterAmount = Math.floorDiv(steamAmount + GTValues.STEAM_PER_WATER - 1, GTValues.STEAM_PER_WATER); + if (depleteInput(FluidUtils.getWater(waterAmount)) || depleteInput(FluidUtils.getDistilledWater(waterAmount))) { + dryHeatCounter = 0; + return true; + } else { + // Add some leniency with explosions. + if (dryHeatCounter < dryHeatMaximum) { + ++dryHeatCounter; + } else { + GTLog.exp.println(this.mName + " was too hot and had no more Water!"); + explodeMultiblock(); // Generate crater + } + return false; + } + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + public int getEfficiencyIncrease() { + return 12; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Thermal Boiler Controller") + .addInfo("Converts Water & Heat into Steam") + .addInfo("Filters raw materials from lava") + .addInfo("Explodes if water is not supplied") + .addInfo("Consult user manual for more information") + .addPollutionAmount(getPollutionPerSecond(null)) + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfoMin("Thermal Containment Casings", 10, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAThermalBoilerActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAThermalBoiler; + } + + @Override + protected int getCasingTextureId() { + return TAE.GTPP_INDEX(1); + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTEThermalBoiler.class) + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Muffler) + .casingIndex(TAE.getIndexFromPage(0, 1)) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 11)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java new file mode 100644 index 0000000000..6f8dd28c03 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java @@ -0,0 +1,823 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gregtech.common.items.IDMetaTool01.BRANCHCUTTER; +import static gregtech.common.items.IDMetaTool01.BUZZSAW_HV; +import static gregtech.common.items.IDMetaTool01.BUZZSAW_LV; +import static gregtech.common.items.IDMetaTool01.BUZZSAW_MV; +import static gregtech.common.items.IDMetaTool01.CHAINSAW_HV; +import static gregtech.common.items.IDMetaTool01.CHAINSAW_LV; +import static gregtech.common.items.IDMetaTool01.CHAINSAW_MV; +import static gregtech.common.items.IDMetaTool01.KNIFE; +import static gregtech.common.items.IDMetaTool01.POCKET_BRANCHCUTTER; +import static gregtech.common.items.IDMetaTool01.POCKET_KNIFE; +import static gregtech.common.items.IDMetaTool01.POCKET_MULTITOOL; +import static gregtech.common.items.IDMetaTool01.POCKET_SAW; +import static gregtech.common.items.IDMetaTool01.POCKET_WIRECUTTER; +import static gregtech.common.items.IDMetaTool01.SAW; +import static gregtech.common.items.IDMetaTool01.WIRECUTTER; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTEnergy; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemShears; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +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 forestry.api.arboriculture.IToolGrafter; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Mods; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.MetaGeneratedTool; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +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.GTModHandler; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.VoidProtectionHelper; +import gregtech.common.items.IDMetaTool01; +import gregtech.common.items.MetaGeneratedTool01; +import gregtech.common.tileentities.machines.MTEHatchInputBusME; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderTreeFarm; + +public class MTETreeFarm extends GTPPMultiBlockBase implements ISurvivalConstructable { + + public static int CASING_TEXTURE_ID; + private static final int TICKS_PER_OPERATION = 100; + private static final int TOOL_DAMAGE_PER_OPERATION = 1; + private static final int TOOL_CHARGE_PER_OPERATION = 32; + + private int mCasing; + public static String mCasingName = "Sterile Farm Casing"; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + public MTETreeFarm(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + } + + public MTETreeFarm(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTETreeFarm(this.mName); + } + + @Override + public String getMachineType() { + return "Tree Farm"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller block for the Tree Growth Simulator") + .addInfo("Farms and harvests trees using EU") + .addInfo("Place a sapling in the controller slot") + .addInfo("Place a tool in an input bus") + .addInfo("Different tools are required for different outputs") + .addInfo("Advanced tools multiply output amount") + .addInfo(" Logs: Saw (1x), Buzzsaw (2x), Chainsaw (4x)") + .addInfo(" Saplings: Branch Cutter (1x), Grafter (3x)") + .addInfo(" Leaves: Shears (1x), Wire Cutter (2x), Automatic Snips (4x)") + .addInfo(" Fruit: Knife (1x)") + .addInfo("Multiple tools can be used at the same time") + .addSeparator() + .addInfo("Work time is fixed at 5 seconds") + .addInfo("Energy input tier multiplies output further") + .addInfo("Output multiplier is equal to: 2*tier^2 - 2*tier + 5") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfoMin(mCasingName, 8, false) + .addInputBus("Any casing", 1) + .addStructureInfo( + EnumChatFormatting.YELLOW + "Stocking Input Busses and Crafting Input Busses/Buffers are not allowed!") + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCATreeFarmActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCATreeFarm; + } + + @Override + protected int getCasingTextureId() { + return CASING_TEXTURE_ID; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 8 && checkHatch(); + } + + @Override + public boolean addInputBusToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + // Tools from a stocking inout bus can not be damaged, this would cause an infinite durability exploit. + // Therefore disallow ME input bus. + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchInputBusME) return false; + return super.addInputBusToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public boolean supportsCraftingMEBuffer() { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public boolean supportsBatchMode() { + // Batch mode would not do anything, processing time is fixed at 100 ticks. + return false; + } + + @Override + public boolean isBatchModeEnabled() { + return false; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiTreeFarm; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })) + .addElement( + 'C', + buildHatchAdder(MTETreeFarm.class) + .atLeast( + InputHatch, + OutputHatch, + InputBus, + OutputBus, + Maintenance, + Energy.or(TTEnergy), + Muffler) + .casingIndex(CASING_TEXTURE_ID) + .dot(1) + .buildAndChain(onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 15)))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); + } + + /* Processing logic. */ + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + if (aStack == null) return false; + if (isValidSapling(aStack)) return true; + /* + * In previous versions, a saw used to go in the controller slot. We do not want an update to stop processing of + * a machine set up like this. Instead, a sapling is placed in this slot at the start of the next operation. + */ + if (aStack.getItem() instanceof MetaGeneratedTool01) return true; + return false; + } + + @Override + public RecipeMap getRecipeMap() { + // Only for NEI, not used in processing logic. + return GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes; + } + + /** + * Valid processing modes (types of output) for the Tree Growth Simulator. + */ + public enum Mode { + LOG, + SAPLING, + LEAVES, + FRUIT + } + + /** + * Edit this to change relative yields for different modes. For example, logs are output at 5 times the rate of + * saplings. + */ + private static final EnumMap modeMultiplier = new EnumMap<>(Mode.class); + static { + modeMultiplier.put(Mode.LOG, 5); + modeMultiplier.put(Mode.SAPLING, 1); + modeMultiplier.put(Mode.LEAVES, 2); + modeMultiplier.put(Mode.FRUIT, 1); + } + + /** + * Return the output multiplier for a given power tier. + * + * @param tier Power tier the machine runs on. + * @return Factor to multiply all outputs by. + */ + private static int getTierMultiplier(int tier) { + /* + * Where does this formula come from? [12:57 AM] boubou_19: i did. Basically Pandoro measured the output of a + * WA-ed farming station for each tier of WA, then i computed the Lagrange interpolating polynomial of his + * dataset, which gave this + */ + return (2 * (tier * tier)) - (2 * tier) + 5; + } + + /** + * Key of this map is the registry name of the sapling, followed by ":", and the sapling's metadata value. + *

+ * The value of the map is a list of products by {@link Mode}. Products for some modes can be null if the tree does + * not produce anything in that mode (for example, it has no fruit). + */ + public static final HashMap> treeProductsMap = new HashMap<>(); + + @Override + public ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Override + @Nonnull + public CheckRecipeResult process() { + if (inputItems == null) { + inputItems = new ItemStack[0]; + } + if (inputFluids == null) { + inputFluids = new FluidStack[0]; + } + + ItemStack sapling = findSapling(); + if (sapling == null) return SimpleCheckRecipeResult.ofFailure("no_sapling"); + + EnumMap outputPerMode = getOutputsForSapling(sapling); + if (outputPerMode == null) { + // This should usually not be possible, outputs for all valid saplings should be defined. + Logger.INFO("No output found for sapling: " + sapling.getDisplayName()); + return SimpleCheckRecipeResult.ofFailure("no_output_for_sapling"); + } + + int tier = Math.max(1, GTUtility.getTier(availableVoltage * availableAmperage)); + int tierMultiplier = getTierMultiplier(tier); + + List outputs = new ArrayList<>(); + for (Mode mode : Mode.values()) { + ItemStack output = outputPerMode.get(mode); + if (output == null) continue; // This sapling has no output in this mode. + + // Find a tool to use in this mode. + int toolMultiplier = useToolForMode(mode, false); + if (toolMultiplier < 0) continue; // No valid tool for this mode found. + + // Increase output by the relevant multipliers. + ItemStack out = output.copy(); + out.stackSize *= tierMultiplier * modeMultiplier.get(mode) * toolMultiplier; + outputs.add(out); + } + + if (outputs.isEmpty()) { + // No outputs can be produced using the tools we have available. + return SimpleCheckRecipeResult.ofFailure("no_tools"); + } + + outputItems = outputs.toArray(new ItemStack[0]); + + VoidProtectionHelper voidProtection = new VoidProtectionHelper().setMachine(machine) + .setItemOutputs(outputItems) + .build(); + if (voidProtection.isItemFull()) { + return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL; + } + + duration = TICKS_PER_OPERATION; + calculatedEut = GTValues.VP[tier]; + + for (Mode mode : Mode.values()) { + if (outputPerMode.get(mode) != null) { + useToolForMode(mode, true); + } + } + + return SimpleCheckRecipeResult.ofSuccess("growing_trees"); + } + }; + } + + /** + * Attempts to find a tool appropriate for the given mode, and damage/discharge it by one use. + * + * @param mode The mode to use. This specifies which tools are valid. + * @param shouldDamage if true, then the tool will have reduced durability/charge + */ + + private int useToolForMode(Mode mode, boolean shouldDamage) { + final ArrayList inputs = getStoredInputs(); + final int inputsSize = inputs.size(); + for (int i = inputsSize - 1; i >= 0; i--) { + ItemStack stack = inputs.get(i); + + int toolMultiplier = getToolMultiplier(stack, mode); + if (toolMultiplier < 0) { + continue; + } + boolean canDamage = shouldDamage + ? GTModHandler.damageOrDechargeItem(stack, TOOL_DAMAGE_PER_OPERATION, TOOL_CHARGE_PER_OPERATION, null) + : GTModHandler.damageOrDechargeItem(stack, 0, 0, null); + if (shouldDamage) { + if (!canDamage || GTModHandler.isElectricItem(stack) + && !GTModHandler.canUseElectricItem(stack, TOOL_CHARGE_PER_OPERATION)) { + depleteInput(stack); + addOutput(stack); + } + } + if (canDamage) { + return toolMultiplier; + } + } + return -1; + } + + /** + * Calculate output multiplier for a given tool and mode. + * + * @param toolStack The tool to use. + * @param mode The mode to use. + * @return Output multiplier for the given tool used in the given mode. If the tool is not appropriate for this + * mode, returns -1. + */ + public static int getToolMultiplier(ItemStack toolStack, Mode mode) { + Item tool = toolStack.getItem(); + int damage = toolStack.getItemDamage(); + switch (mode) { + case LOG: + if (tool instanceof MetaGeneratedTool01) { + + if (damage == SAW.ID || damage == POCKET_SAW.ID || damage == POCKET_MULTITOOL.ID) { + return 1; + } + + if (damage == BUZZSAW_LV.ID || damage == BUZZSAW_MV.ID || damage == BUZZSAW_HV.ID) { + return 2; + } + + if (damage == CHAINSAW_LV.ID || damage == CHAINSAW_MV.ID || damage == CHAINSAW_HV.ID) { + return 4; + } + } + break; + + case SAPLING: + if (tool instanceof MetaGeneratedTool01 + && (damage == BRANCHCUTTER.ID || damage == POCKET_BRANCHCUTTER.ID + || damage == POCKET_MULTITOOL.ID)) { + return 1; + } + if (tool instanceof IToolGrafter && tool.isDamageable()) { + return 3; + } + break; + + case LEAVES: + // Do not allow unbreakable tools. Operation should have a running cost. + if (tool instanceof ItemShears && tool.isDamageable()) { + return 1; + } + if (tool instanceof MetaGeneratedTool01) { + if (damage == POCKET_MULTITOOL.ID) { + return 1; + } + if (damage == WIRECUTTER.ID || damage == POCKET_WIRECUTTER.ID) { + return 2; + } + } + if (tool instanceof MetaGeneratedGregtechTools) { + if (toolStack.getItemDamage() == MetaGeneratedGregtechTools.ELECTRIC_SNIPS) { + return 4; + } + } + break; + + case FRUIT: + if (tool instanceof MetaGeneratedTool01 + && (damage == KNIFE.ID || damage == POCKET_KNIFE.ID || damage == POCKET_MULTITOOL.ID)) { + return 1; + } + break; + } + + // No valid tool was found. + return -1; + } + + /* Handling saplings. */ + + /** + * Finds a valid sapling from input buses, and places it into the controller slot. + * + * @return The sapling that was found (now in the controller slot). + */ + private ItemStack findSapling() { + ItemStack controllerSlot = getControllerSlot(); + + if (isValidSapling(controllerSlot)) { + return controllerSlot; + } + + if (controllerSlot != null) { + // Non-sapling item in controller slot. This could be a saw from an older version of the TGS. + // We first try to swap it with a sapling from an input bus to not interrupt existing setups. + if (!legacyToolSwap()) { + // Swap failed, output whatever is blocking the slot. + addOutput(controllerSlot); + mInventory[1] = null; + } + } + + // Here controller slot is empty, find a valid sapling to use. + for (ItemStack stack : getStoredInputs()) { + if (isValidSapling(stack)) { + mInventory[1] = stack.splitStack(1); + return mInventory[1]; + } + } + + // No saplings were found. + return null; + } + + /** + * In previous versions, the saw used to be placed in the controller slot and the sapling into an input bus. We do + * not want to break existing setups like this, so we attempt to swap the two if possible. + * + * @return True on success, false otherwise. + */ + private boolean legacyToolSwap() { + ItemStack controllerSlot = getControllerSlot(); + if (controllerSlot == null || !(controllerSlot.getItem() instanceof MetaGeneratedTool01)) return false; + + for (MTEHatchInputBus inputBus : filterValidMTEs(mInputBusses)) { + ItemStack[] inventory = inputBus.getRealInventory(); + for (int slot = 0; slot < inventory.length; ++slot) { + if (isValidSapling(inventory[slot])) { + // Do the swap. + mInventory[1] = inventory[slot]; + inventory[slot] = controllerSlot; + inputBus.updateSlots(); + return true; + } + } + } + return false; + } + + /** + * Check if an ItemStack is a sapling that can be farmed. + * + * @param stack An ItemStack. + * @return True if stack is a valid sapling that can be farmed. + */ + private boolean isValidSapling(ItemStack stack) { + if (stack == null) return false; + String registryName = Item.itemRegistry.getNameForObject(stack.getItem()); + return treeProductsMap.containsKey(registryName + ":" + stack.getItemDamage()) + || "Forestry:sapling".equals(registryName); + } + + /** + * Get a list of possible outputs for a sapling, for each mode. This is either recovered from + * {@link #treeProductsMap}, or generated from stats of Forestry saplings. + * + * @param sapling A sapling to farm. + * @return A map of outputs for each mode. Outputs for some modes might be null. + */ + private static EnumMap getOutputsForSapling(ItemStack sapling) { + String registryName = Item.itemRegistry.getNameForObject(sapling.getItem()); + if ("Forestry:sapling".equals(registryName)) { + return getOutputsForForestrySapling(sapling); + } else { + return treeProductsMap.get(registryName + ":" + sapling.getItemDamage()); + } + } + + /** + * Calculate outputs for Forestry saplings. Default amounts stored in {@link #treeProductsMap} are adjusted based + * the genetics of the input sapling. + *

+ * Relevant stats: + *

    + *
  • height, girth: Affects log output.
  • + *
  • fertility (called Saplings in game): Affects sapling output.
  • + *
  • yield: Affects fruit output.
  • + *
+ * See {@link forestry.core.genetics.alleles.EnumAllele} for detailed numeric values for each allele. + * + * @param sapling A sapling to farm. Must be a Forestry sapling with a valid genome. + * @return A map of outputs for each mode. Outputs for some modes might be null. + */ + private static EnumMap getOutputsForForestrySapling(ItemStack sapling) { + ITree tree = TreeManager.treeRoot.getMember(sapling); + if (tree == null) return null; + + String speciesUUID = tree.getIdent(); + + EnumMap defaultMap = treeProductsMap.get("Forestry:sapling:" + speciesUUID); + if (defaultMap == null) return null; + + // We need to make a new map so that we don't modify the stored amounts of outputs. + EnumMap adjustedMap = new EnumMap<>(Mode.class); + + ItemStack log = defaultMap.get(Mode.LOG); + if (log != null) { + double height = Math.max( + 3 * (tree.getGenome() + .getHeight() - 1), + 0) + 1; + double girth = tree.getGenome() + .getGirth(); + + log = log.copy(); + log.stackSize = (int) (log.stackSize * height * girth); + adjustedMap.put(Mode.LOG, log); + } + + ItemStack saplingOut = defaultMap.get(Mode.SAPLING); + if (saplingOut != null) { + // Lowest = 0.01 ... Average = 0.05 ... Highest = 0.3 + double fertility = tree.getGenome() + .getFertility() * 10; + + // Return a copy of the *input* sapling, retaining its genetics. + int stackSize = Math.max(1, (int) (saplingOut.stackSize * fertility)); + saplingOut = sapling.copy(); + saplingOut.stackSize = stackSize; + adjustedMap.put(Mode.SAPLING, saplingOut); + } + + ItemStack leaves = defaultMap.get(Mode.LEAVES); + if (leaves != null) { + adjustedMap.put(Mode.LEAVES, leaves.copy()); + } + + ItemStack fruit = defaultMap.get(Mode.FRUIT); + if (fruit != null) { + // Lowest = 0.025 ... Average = 0.2 ... Highest = 0.4 + double yield = tree.getGenome() + .getYield() * 10; + + fruit = fruit.copy(); + fruit.stackSize = (int) (fruit.stackSize * yield); + adjustedMap.put(Mode.FRUIT, fruit); + } + + return adjustedMap; + } + + /* Recipe registration. */ + + /** + * Registers outputs for a sapling. This method assumes that output in mode SAPLING is the same as the input + * sapling. Output amount is further modified by mode, machine tier, and tool used. Recipes are added in + * {@link RecipeLoaderTreeFarm}. + * + * @param sapling The input sapling to farm, and also the output in mode SAPLING. + * @param log ItemStack to output in mode LOG. + * @param leaves ItemStack to output in mode LEAVES. + * @param fruit ItemStack to output in mode FRUIT. + */ + public static void registerTreeProducts(ItemStack sapling, ItemStack log, ItemStack leaves, ItemStack fruit) { + registerTreeProducts(sapling, log, sapling, leaves, fruit); + } + + /** + * Registers outputs for a sapling. Output amount is further modified by mode, machine tier, and tool used. Recipes + * are added in {@link RecipeLoaderTreeFarm}. + * + * @param saplingIn The input sapling to farm. + * @param log ItemStack to output in mode LOG. + * @param saplingOut ItemStack to output in mode SAPLING. + * @param leaves ItemStack to output in mode LEAVES. + * @param fruit ItemStack to output in mode FRUIT. + */ + public static void registerTreeProducts(ItemStack saplingIn, ItemStack log, ItemStack saplingOut, ItemStack leaves, + ItemStack fruit) { + String key = Item.itemRegistry.getNameForObject(saplingIn.getItem()) + ":" + saplingIn.getItemDamage(); + EnumMap map = new EnumMap<>(Mode.class); + if (log != null) map.put(Mode.LOG, log); + if (saplingOut != null) map.put(Mode.SAPLING, saplingOut); + if (leaves != null) map.put(Mode.LEAVES, leaves); + if (fruit != null) map.put(Mode.FRUIT, fruit); + treeProductsMap.put(key, map); + + if (!addFakeRecipeToNEI(saplingIn, log, saplingOut, leaves, fruit)) { + Logger.INFO("Registering NEI fake recipe for " + key + " failed!"); + } + } + + /** + * For Forestry trees, the output amounts depend on the genetics of the sapling. Here we register only the types of + * items to output. In {@link #getOutputsForForestrySapling(ItemStack)} these outputs are then multiplied according + * to the stats of the real sapling that is in the controller slot. + */ + public static void registerForestryTree(String speciesUID, ItemStack sapling, ItemStack log, ItemStack leaves, + ItemStack fruit) { + String key = "Forestry:sapling:" + speciesUID; + EnumMap map = new EnumMap<>(Mode.class); + map.put(Mode.LOG, log); + map.put(Mode.SAPLING, sapling); + map.put(Mode.LEAVES, leaves); + map.put(Mode.FRUIT, fruit); + treeProductsMap.put(key, map); + + // In the NEI recipe we want to display outputs adjusted for the default genetics of this tree type. + // To do this we use the same method as when calculating real outputs. + map = getOutputsForForestrySapling(sapling); + if (map == null) { + Logger.INFO("Could not create Forestry tree output map for " + speciesUID); + return; + } + addFakeRecipeToNEI( + sapling, + map.get(Mode.LOG), + map.get(Mode.SAPLING), + map.get(Mode.LEAVES), + map.get(Mode.FRUIT)); + } + + /** + * This array is used to get the rotating display of items in NEI showing all possible tools for a given mode. + */ + private static final ItemStack[][] altToolsForNEI; + static { + MetaGeneratedTool toolInstance = MetaGeneratedTool01.INSTANCE; + altToolsForNEI = new ItemStack[][] { + // Mode.LOG + { toolInstance.getToolWithStats(SAW.ID, 1, null, null, null), + toolInstance.getToolWithStats(POCKET_SAW.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.BUZZSAW_LV.ID, 1, null, null, null), + toolInstance.getToolWithStats(CHAINSAW_LV.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.BUZZSAW_MV.ID, 1, null, null, null), + toolInstance.getToolWithStats(CHAINSAW_MV.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.BUZZSAW_HV.ID, 1, null, null, null), + toolInstance.getToolWithStats(CHAINSAW_HV.ID, 1, null, null, null), }, + // Mode.SAPLING + { toolInstance.getToolWithStats(IDMetaTool01.BRANCHCUTTER.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.POCKET_BRANCHCUTTER.ID, 1, null, null, null), + GTModHandler.getModItem(Mods.Forestry.ID, "grafter", 1, 0), }, + // Mode.LEAVES + { new ItemStack(Items.shears), + toolInstance.getToolWithStats(IDMetaTool01.WIRECUTTER.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.POCKET_WIRECUTTER.ID, 1, null, null, null), + MetaGeneratedGregtechTools.getInstance() + .getToolWithStats(MetaGeneratedGregtechTools.ELECTRIC_SNIPS, 1, null, null, null), }, + // Mode.FRUIT + { toolInstance.getToolWithStats(IDMetaTool01.KNIFE.ID, 1, null, null, null), + toolInstance.getToolWithStats(IDMetaTool01.POCKET_KNIFE.ID, 1, null, null, null), } }; + } + + /** + * Add a recipe for this tree to NEI. These recipes are only used in NEI, they are never used for processing logic. + * + * @return True if the recipe was added successfully. + */ + public static boolean addFakeRecipeToNEI(ItemStack saplingIn, ItemStack log, ItemStack saplingOut, ItemStack leaves, + ItemStack fruit) { + int recipeCount = GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.getAllRecipes() + .size(); + + // Sapling goes into the "special" slot. + ItemStack specialStack = saplingIn.copy(); + specialStack.stackSize = 0; + + /* + * Calculate the correct amount of outputs for each mode. The amount displayed in NEI should take into account + * the mode multiplier, but not tool/tier multipliers as those can change dynamically. If the sapling has an + * output in this mode, also add the tools usable for this mode as inputs. + */ + ItemStack[][] inputStacks = new ItemStack[Mode.values().length][]; + ItemStack[] outputStacks = new ItemStack[Mode.values().length]; + + for (Mode mode : Mode.values()) { + ItemStack output = switch (mode) { + case LOG -> log; + case SAPLING -> saplingOut; + case LEAVES -> leaves; + case FRUIT -> fruit; + }; + if (output != null) { + int ordinal = mode.ordinal(); + inputStacks[ordinal] = altToolsForNEI[ordinal]; + outputStacks[ordinal] = output.copy(); + outputStacks[ordinal].stackSize *= modeMultiplier.get(mode); + } + } + + Logger.INFO( + "Adding Tree Growth Simulation NEI recipe for " + specialStack.getDisplayName() + + " -> " + + ItemUtils.getArrayStackNames(outputStacks)); + + GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.addFakeRecipe( + false, + new GTRecipe.GTRecipe_WithAlt( + false, + null, // All inputs are taken from aAtl argument. + outputStacks, + specialStack, + null, + null, + null, + TICKS_PER_OPERATION, + 0, + recipeCount, // special value, also sorts recipes correctly in order of addition. + inputStacks)); + + return GTPPRecipeMaps.treeGrowthSimulatorFakeRecipes.getAllRecipes() + .size() > recipeCount; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java deleted file mode 100644 index 7e5200e16c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ /dev/null @@ -1,393 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.InputBus; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; - -import java.util.stream.Stream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.GregTech_API; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -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_Input; -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_Recipe; -import gregtech.api.util.GT_StreamUtil; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.item.chemistry.AgriculturalChem; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; - -public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mLevel = -1; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - private int checkMeta; - private static final Class cofhWater; - - static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); - } - - public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_AlgaePondBase(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_AlgaePondBase(this.mName); - } - - @Override - public String getMachineType() { - return "Algae Pond"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Grows Algae!") - .addInfo("Controller Block for the Algae Farm") - .addInfo("Provide compost to boost production by one tier") - .addInfo("Does not require power or maintenance") - .addInfo("All Machine Casings must be the same tier, this dictates machine speed.") - .addInfo("Requires one Input Hatch that matches the tier of the Casings") - .addInfo("Fill Input Hatch with Water to fill the inside of the multiblock.") - .addPollutionAmount(getPollutionPerSecond(null)) - .addSeparator() - .beginStructureBlock(9, 3, 9, true) - .addController("Front Center") - .addCasingInfoMin("Machine Casings", 64, true) - .addCasingInfoMin("Sterile Farm Casings", 64, false) - .addInputBus("Any Casing", 1) - .addOutputBus("Any Casing", 1) - .addInputHatch("Any Casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - public void setMeta(int meta) { - checkMeta = meta; - } - - public int getMeta() { - return checkMeta; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { - { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", - "X X", "XXXXXXXXX" }, - { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", - "X X", "XXXXXXXXX" }, - { "CCCC~CCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", - "CCCCCCCCC", "CCCCCCCCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_AlgaePondBase.class).atLeast(InputHatch, InputBus, OutputBus) - .casingIndex(TAE.getIndexFromPage(1, 15)) - .dot(1) - .build(), - onElementPass( - x -> ++x.mCasing, - addTieredBlock( - GregTech_API.sBlockCasings1, - GregtechMTE_AlgaePondBase::setMeta, - GregtechMTE_AlgaePondBase::getMeta, - 10)), - onElementPass( - x -> ++x.mCasing, - addTieredBlock( - TT_Container_Casings.sBlockCasingsNH, - GregtechMTE_AlgaePondBase::setMeta, - GregtechMTE_AlgaePondBase::getMeta, - 10, - 15)))) - .addElement('X', ofBlock(ModBlocks.blockCasings2Misc, 15)) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 4, 2, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 4, 2, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - mLevel = 0; - checkMeta = 0; - - if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 - && checkMeta > 0 - && mInputHatches.size() >= 1 - && mOutputBusses.size() >= 1) { - mLevel = checkMeta - 1; - for (GT_MetaTileEntity_Hatch_Input inputHatch : mInputHatches) { - if (inputHatch.mTier < mLevel) { - return false; - } - } - return true; - } - return false; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCDAlgaePondBaseActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCDAlgaePondBase; - } - - @Override - protected int getCasingTextureId() { - int aID = TAE.getIndexFromPage(1, 15); - if (mLevel > -1) { - aID = mLevel; - } - return aID; - } - - @Override - public int getMaxParallelRecipes() { - return 2; - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - - final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; - final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; h++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (isNotStaticWater(tBlock, tMeta)) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = Blocks.water; - aBaseMetaTileEntity.getWorld() - .setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, - fluidUsed); - } - } - } - } - } - tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { - ++tAmount; - // Logger.INFO("Found Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 49; - - if (isValidWater) { - Logger.INFO("Filled structure."); - return true; - } else { - return false; - } - } - - private boolean isNotStaticWater(Block block, byte meta) { - return block == Blocks.air || block == Blocks.flowing_water - || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) - || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerSecond(final ItemStack aStack) { - return CORE.ConfigSwitches.pollutionPerSecondMultiAlgaePond; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - // Silly Client Syncing - if (aBaseMetaTileEntity.isClientSide()) { - this.mLevel = getCasingTier(); - } - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @Nonnull - @Override - protected Stream findRecipeMatches(@Nullable RecipeMap map) { - return GT_StreamUtil - .ofNullable(RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(mLevel, isUsingCompost(inputItems))); - } - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (!checkForWater()) { - return SimpleCheckRecipeResult.ofFailure("no_water"); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - }.setEuModifier(0F) - .setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - private boolean isUsingCompost(ItemStack[] aItemInputs) { - ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); - for (ItemStack i : aItemInputs) { - if (GT_Utility.areStacksEqual(aCompost, i)) { - if (i.stackSize >= RecipeLoader_AlgaeFarm.compostForTier(mLevel)) { - return true; - } - } - } - return false; - } - - private int getCasingTier() { - if (this.getBaseMetaTileEntity() - .getWorld() == null) { - return 0; - } - try { - Block aInitStructureCheck; - int aInitStructureCheckMeta; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int xDir = aBaseMetaTileEntity.getBackFacing().offsetX; - int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ; - aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); - aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); - if (aInitStructureCheck == GregTech_API.sBlockCasings1 - || aInitStructureCheck == TT_Container_Casings.sBlockCasingsNH) { - return aInitStructureCheckMeta; - } - return 0; - } catch (Throwable t) { - t.printStackTrace(); - return 0; - } - } - - @Override - public boolean getDefaultHasMaintenanceChecks() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java new file mode 100644 index 0000000000..1223158f31 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java @@ -0,0 +1,392 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; + +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.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +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.GTRecipe; +import gregtech.api.util.GTStreamUtil; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderAlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import tectech.thing.casing.TTCasingsContainer; + +public class MTEAlgaePondBase extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mLevel = -1; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + private int checkMeta; + private static final Class cofhWater; + + static { + cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + } + + public MTEAlgaePondBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEAlgaePondBase(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEAlgaePondBase(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Grows Algae!") + .addInfo("Controller Block for the Algae Farm") + .addInfo("Provide compost to boost production by one tier") + .addInfo("Does not require power or maintenance") + .addInfo("All Machine Casings must be the same tier, this dictates machine speed.") + .addInfo("Requires one Input Hatch that matches the tier of the Casings") + .addInfo("Fill Input Hatch with Water to fill the inside of the multiblock.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfoMin("Machine Casings", 64, true) + .addCasingInfoMin("Sterile Farm Casings", 64, false) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + public void setMeta(int meta) { + checkMeta = meta; + } + + public int getMeta() { + return checkMeta; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { + { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", + "X X", "XXXXXXXXX" }, + { "XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", + "X X", "XXXXXXXXX" }, + { "CCCC~CCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", + "CCCCCCCCC", "CCCCCCCCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEAlgaePondBase.class).atLeast(InputHatch, InputBus, OutputBus) + .casingIndex(TAE.getIndexFromPage(1, 15)) + .dot(1) + .build(), + onElementPass( + x -> ++x.mCasing, + addTieredBlock( + GregTechAPI.sBlockCasings1, + MTEAlgaePondBase::setMeta, + MTEAlgaePondBase::getMeta, + 10)), + onElementPass( + x -> ++x.mCasing, + addTieredBlock( + TTCasingsContainer.sBlockCasingsNH, + MTEAlgaePondBase::setMeta, + MTEAlgaePondBase::getMeta, + 10, + 15)))) + .addElement('X', ofBlock(ModBlocks.blockCasings2Misc, 15)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 4, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 4, 2, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + checkMeta = 0; + + if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 + && checkMeta > 0 + && mInputHatches.size() >= 1 + && mOutputBusses.size() >= 1) { + mLevel = checkMeta - 1; + for (MTEHatchInput inputHatch : mInputHatches) { + if (inputHatch.mTier < mLevel) { + return false; + } + } + return true; + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCDAlgaePondBaseActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCDAlgaePondBase; + } + + @Override + protected int getCasingTextureId() { + int aID = TAE.getIndexFromPage(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + return aID; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (isNotStaticWater(tBlock, tMeta)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld() + .setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, + fluidUsed); + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 49; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } else { + return false; + } + } + + private boolean isNotStaticWater(Block block, byte meta) { + return block == Blocks.air || block == Blocks.flowing_water + || block == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater) + || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return GTPPCore.ConfigSwitches.pollutionPerSecondMultiAlgaePond; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTier(); + } + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected Stream findRecipeMatches(@Nullable RecipeMap map) { + return GTStreamUtil + .ofNullable(RecipeLoaderAlgaeFarm.getTieredRecipeFromCache(mLevel, isUsingCompost(inputItems))); + } + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (!checkForWater()) { + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }.setEuModifier(0F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GTUtility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= RecipeLoaderAlgaeFarm.compostForTier(mLevel)) { + return true; + } + } + } + return false; + } + + private int getCasingTier() { + if (this.getBaseMetaTileEntity() + .getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = aBaseMetaTileEntity.getBackFacing().offsetX; + int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ; + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); + if (aInitStructureCheck == GregTechAPI.sBlockCasings1 + || aInitStructureCheck == TTCasingsContainer.sBlockCasingsNH) { + return aInitStructureCheckMeta; + } + return 0; + } catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java deleted file mode 100644 index b359a3b831..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ /dev/null @@ -1,676 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; -import static gregtech.api.enums.GT_HatchElement.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_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.filterByMTETier; -import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gregtech.api.util.GT_Utility.filterValidMTEs; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.StructureLibAPI; -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.ISurvivalBuildEnvironment; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureUtility; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.SoundResource; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.GregTechTileClientEvents; -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_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_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -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_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.IDualInputHatch; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.data.Triplet; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase - implements ISurvivalConstructable { - - private int mSolidCasingTier = 0; - private int mMachineCasingTier = 0; - private int mPipeCasingTier = 0; - private int mCoilTier = 0; - private HeatingCoilLevel checkCoil; - private int[] checkCasing = new int[8]; - private int checkMachine; - private int checkPipe; - private int maxTierOfHatch; - private int mCasing; - private static IStructureDefinition STRUCTURE_DEFINITION = null; - - private final ArrayList mCatalystBuses = new ArrayList<>(); - - private static final HashMap> mTieredBlockRegistry = new HashMap<>(); - - public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_ChemicalPlant(final String aName) { - super(aName); - } - - public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { - Triplet aCasingData = new Triplet<>(aBlock, aMeta, aCasingTextureID); - if (mTieredBlockRegistry.containsKey(aTier)) { - CORE.crash( - "Tried to register a Machine casing for tier " + aTier - + " to the Chemical Plant, however this tier already contains one."); - } - mTieredBlockRegistry.put(aTier, aCasingData); - return true; - } - - private static int getCasingTextureIdForTier(int aTier) { - if (!mTieredBlockRegistry.containsKey(aTier)) { - return 10; - } - int aCasingID = mTieredBlockRegistry.get(aTier) - .getValue_3(); - // Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); - return aCasingID; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_ChemicalPlant(this.mName); - } - - @Override - public String getMachineType() { - return "Chemical Plant"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Chemical Plant") - .addInfo("Heavy Industry, now right at your doorstep!") - .addInfo("Please read the user manual for more information on construction and usage") - .addSeparator() - .addController("Bottom Center") - .addStructureHint("Catalyst Housing", 1) - .addInputBus("Bottom Casing", 1) - .addOutputBus("Bottom Casing", 1) - .addInputHatch("Bottom Casing", 1) - .addOutputHatch("Bottom Casing", 1) - .addEnergyHatch("Bottom Casing", 1) - .addMaintenanceHatch("Bottom Casing", 1) - .addSubChannelUsage("casing", "metal machine casing") - .addSubChannelUsage("machine", "tier machine casing") - .addSubChannelUsage("coil", "heating coil blocks") - .addSubChannelUsage("pipe", "pipe casing blocks") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - public void setMachineMeta(int meta) { - checkMachine = meta; - } - - public int getMachineMeta() { - return checkMachine; - } - - public void setPipeMeta(int meta) { - checkPipe = meta; - } - - public int getPipeMeta() { - return checkPipe; - } - - public void setCoilMeta(HeatingCoilLevel meta) { - checkCoil = meta; - } - - public HeatingCoilLevel getCoilMeta() { - return checkCoil; - } - - @Override - public IStructureDefinition getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - IStructureElement allCasingsElement = withChannel( - "casing", - ofChain( - IntStream.range(0, 8) - .mapToObj(GregtechMTE_ChemicalPlant::ofSolidCasing) - .collect(Collectors.toList()))); - STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape( - mName, - transpose( - new String[][] { - { "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX" }, - { "X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X" }, - { "X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X" }, - { "X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X" }, - { "X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X" }, - { "X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X" }, - { "CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC" }, })) - .addElement( - 'C', - ofChain( - buildHatchAdder(GregtechMTE_ChemicalPlant.class).atLeast(Maintenance) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_ChemicalPlant.class) - .atLeast(InputHatch, OutputHatch, InputBus, OutputBus) - .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) - .hatchItemFilterAnd( - (t, s) -> filterByMTETier( - Integer.MIN_VALUE, - s.stackSize >= 10 ? Integer.MAX_VALUE : s.stackSize)) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - buildHatchAdder(GregtechMTE_ChemicalPlant.class) - .hatchClass(GT_MetaTileEntity_Hatch_Catalysts.class) - .shouldReject(t -> t.mCatalystBuses.size() >= 1) - .adder(GregtechMTE_ChemicalPlant::addChemicalPlantList) - .casingIndex(getCasingTextureID()) - .dot(1) - .build(), - allCasingsElement)) - .addElement('X', allCasingsElement) - .addElement( - 'M', - withChannel( - "machine", - addTieredBlock( - GregTech_API.sBlockCasings1, - GregtechMTE_ChemicalPlant::setMachineMeta, - GregtechMTE_ChemicalPlant::getMachineMeta, - 10))) - .addElement( - 'H', - withChannel( - "coil", - ofCoil(GregtechMTE_ChemicalPlant::setCoilMeta, GregtechMTE_ChemicalPlant::getCoilMeta))) - .addElement( - 'P', - withChannel( - "pipe", - addTieredBlock( - GregTech_API.sBlockCasings2, - GregtechMTE_ChemicalPlant::setPipeMeta, - GregtechMTE_ChemicalPlant::getPipeMeta, - 12, - 16))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - private static IStructureElement ofSolidCasing(int aIndex) { - return new IStructureElement() { - - @Override - public boolean check(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z) { - if (check(aIndex, world, x, y, z)) { - t.checkCasing[aIndex]++; - t.mCasing++; - return true; - } else return false; - } - - private boolean check(int aIndex, World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - Block target = mTieredBlockRegistry.get(aIndex) - .getValue_1(); - int targetMeta = mTieredBlockRegistry.get(aIndex) - .getValue_2(); - return target.equals(block) && meta == targetMeta; - } - - int getIndex(int size) { - if (size > 8) size = 8; - return size - 1; - } - - @Override - public boolean spawnHint(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle( - world, - x, - y, - z, - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_1(), - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_2()); - return true; - } - - @Override - public boolean placeBlock(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, - ItemStack trigger) { - return world.setBlock( - x, - y, - z, - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_1(), - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_2(), - 3); - } - - @Nullable - @Override - public BlocksToPlace getBlocksToPlace(GregtechMTE_ChemicalPlant gregtechMTE_chemicalPlant, World world, - int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { - return BlocksToPlace.create( - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_1(), - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_2()); - } - - @Override - public PlaceResult survivalPlaceBlock(GregtechMTE_ChemicalPlant t, World world, int x, int y, int z, - ItemStack trigger, AutoPlaceEnvironment env) { - if (check(getIndex(trigger.stackSize), world, x, y, z)) return PlaceResult.SKIP; - return StructureUtility.survivalPlaceBlock( - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_1(), - mTieredBlockRegistry.get(getIndex(trigger.stackSize)) - .getValue_2(), - world, - x, - y, - z, - env.getSource(), - env.getActor(), - env.getChatter()); - } - }; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 3, 6, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 3, 6, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - for (int i = 0; i < 8; i++) { - checkCasing[i] = 0; - } - checkPipe = 0; - checkMachine = 0; - mSolidCasingTier = 0; - mMachineCasingTier = 0; - mPipeCasingTier = 0; - mCoilTier = 0; - maxTierOfHatch = 0; - mCatalystBuses.clear(); - setCoilMeta(HeatingCoilLevel.None); - if (checkPiece(mName, 3, 6, 0) && mCasing >= 70) { - for (int i = 0; i < 8; i++) { - if (checkCasing[i] == mCasing) { - mSolidCasingTier = i; - } else if (checkCasing[i] > 0) return false; - } - mMachineCasingTier = checkMachine - 1; - mPipeCasingTier = checkPipe - 12; - mCoilTier = checkCoil.getTier(); - getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData()); - updateHatchTexture(); - return (mMachineCasingTier >= 9 || mMachineCasingTier >= maxTierOfHatch) && mCatalystBuses.size() <= 1; - } - return false; - } - - public void updateHatchTexture() { - for (GT_MetaTileEntity_Hatch h : mCatalystBuses) h.updateTexture(getCasingTextureID()); - for (IDualInputHatch h : mDualInputHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); - for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); - } - - public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier); - return addToMachineList(aTileEntity, aBaseCasingIndex); - } - } - return false; - } - - @Override - protected SoundResource getProcessStartSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.oMCAChemicalPlantActive; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.oMCAChemicalPlant; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureID(); - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.chemicalPlantRecipes; - } - - @Override - public int getMaxParallelRecipes() { - return 2 * getPipeCasingTier(); - } - - private int getSolidCasingTier() { - return this.mSolidCasingTier; - } - - private int getMachineCasingTier() { - return mMachineCasingTier; - } - - private int getPipeCasingTier() { - return mPipeCasingTier; - } - - private int getCasingTextureID() { - // Check the Tier Client Side - int aTier = mSolidCasingTier; - return getCasingTextureIdForTier(aTier); - } - - public boolean addToMachineList(IGregTechTileEntity aTileEntity) { - int aMaxTier = getMachineCasingTier(); - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock aMachineBlock) { - int aTileTier = aMachineBlock.mTier; - if (aTileTier > aMaxTier) { - log("Hatch tier too high."); - return false; - } else { - return addToMachineList(aTileEntity, getCasingTextureID()); - } - } else { - log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. - return false; - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); - aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); - aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); - aNBT.setInteger("mCoilTier", this.mCoilTier); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); - mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); - mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); - mCoilTier = aNBT.getInteger("mCoilTier"); - } - - @Override - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { - log("Found GT_MetaTileEntity_Hatch_Catalysts"); - return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); - } - return super.addToMachineList(aTileEntity, aBaseCasingIndex); - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public int getMaxCatalystDurability() { - return 50; - } - - @Override - public byte getUpdateData() { - return (byte) mSolidCasingTier; - } - - @Override - public void receiveClientEvent(byte aEventID, byte aValue) { - super.receiveClientEvent(aEventID, aValue); - if (aEventID == GregTechTileClientEvents.CHANGE_CUSTOM_DATA && (aValue & 0x80) == 0) { - // received an update data from above method - // if no &0x80 clause it might catch the noop texture page event - mSolidCasingTier = aValue; - } - } - - private void damageCatalyst(@Nonnull ItemStack aStack, int minParallel) { - // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. - if (!isCatalystDamageable()) return; - for (int i = 0; i < minParallel; i++) { - if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - if (damage >= getMaxCatalystDurability()) { - addOutput(CI.getEmptyCatalyst(1)); - aStack.stackSize -= 1; - return; - } else { - setDamage(aStack, damage); - } - } - } - } - - private boolean isCatalystDamageable() { - return this.mCoilTier < 10 || this.mPipeCasingTier < 4; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - ItemStack catalyst; - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (recipe.mSpecialValue > mSolidCasingTier) { - return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue + 1); - } - // checks if it has a catalyst - ItemStack catalystInRecipe = null; - for (ItemStack item : recipe.mInputs) { - if (ItemUtils.isCatalyst(item)) { - catalystInRecipe = item; - break; - } - } - - if (catalystInRecipe != null) { - catalyst = findCatalyst(getCatalystInputs().toArray(new ItemStack[0]), catalystInRecipe); - if (catalyst == null) { - return SimpleCheckRecipeResult.ofFailure("no_catalyst"); - } - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @NotNull - @Override - public CheckRecipeResult process() { - ArrayList inputItemsList = new ArrayList<>(Arrays.asList(inputItems)); - inputItemsList.addAll(getCatalystInputs()); - inputItems = inputItemsList.toArray(new ItemStack[0]); - return super.process(); - } - - @NotNull - @Override - protected CheckRecipeResult onRecipeStart(@NotNull GT_Recipe recipe) { - if (catalyst != null) { - damageCatalyst(catalyst, getCurrentParallels()); - } - return super.onRecipeStart(recipe); - } - }.setMaxParallelSupplier(this::getMaxParallelRecipes); - } - - @Override - protected void setupProcessingLogic(ProcessingLogic logic) { - super.setupProcessingLogic(logic); - // Same speed bonus as pyro oven - logic.setSpeedBonus(2F / (1 + this.mCoilTier)); - } - - @Override - public void updateSlots() { - super.updateSlots(); - for (GT_MetaTileEntity_Hatch_Catalysts h : mCatalystBuses) { - h.updateSlots(); - h.tryFillUsageSlots(); - } - } - - private ItemStack findCatalyst(ItemStack[] aItemInputs, ItemStack catalyst) { - if (aItemInputs != null) { - for (ItemStack item : aItemInputs) { - if (GT_Utility.areStacksEqual(item, catalyst, true)) { - return item; - } - } - } - return null; - } - - private int getDamage(@Nonnull ItemStack aStack) { - return ItemGenericChemBase.getCatalystDamage(aStack); - } - - private void setDamage(@Nonnull ItemStack aStack, int aAmount) { - ItemGenericChemBase.setCatalystDamage(aStack, aAmount); - } - - /* - * Catalyst Handling - */ - public ArrayList getCatalystInputs() { - ArrayList tItems = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_Catalysts tHatch : filterValidMTEs(mCatalystBuses)) { - AutoMap aHatchContent = tHatch.getContentUsageSlots(); - if (!aHatchContent.isEmpty()) { - tItems.addAll(aHatchContent); - } - } - return tItems; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java new file mode 100644 index 0000000000..2046de6c1c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java @@ -0,0 +1,670 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.filterByMTETier; +import static gregtech.api.util.GTStructureUtility.ofCoil; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +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.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureUtility; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.SoundResource; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.GregTechTileClientEvents; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +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.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.MTEHatchCatalysts; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEChemicalPlant extends GTPPMultiBlockBase implements ISurvivalConstructable { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + private HeatingCoilLevel checkCoil; + private int[] checkCasing = new int[8]; + private int checkMachine; + private int checkPipe; + private int maxTierOfHatch; + private int mCasing; + private static IStructureDefinition STRUCTURE_DEFINITION = null; + + private final ArrayList mCatalystBuses = new ArrayList<>(); + + private static final HashMap> mTieredBlockRegistry = new HashMap<>(); + + public MTEChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEChemicalPlant(final String aName) { + super(aName); + } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + Triplet aCasingData = new Triplet<>(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + GTPPCore.crash( + "Tried to register a Machine casing for tier " + aTier + + " to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + return true; + } + + private static int getCasingTextureIdForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 10; + } + int aCasingID = mTieredBlockRegistry.get(aTier) + .getValue_3(); + // Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); + return aCasingID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Chemical Plant") + .addInfo("Heavy Industry, now right at your doorstep!") + .addInfo("Please read the user manual for more information on construction and usage") + .addSeparator() + .addController("Bottom Center") + .addStructureHint("Catalyst Housing", 1) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addSubChannelUsage("casing", "metal machine casing") + .addSubChannelUsage("machine", "tier machine casing") + .addSubChannelUsage("coil", "heating coil blocks") + .addSubChannelUsage("pipe", "pipe casing blocks") + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + public void setMachineMeta(int meta) { + checkMachine = meta; + } + + public int getMachineMeta() { + return checkMachine; + } + + public void setPipeMeta(int meta) { + checkPipe = meta; + } + + public int getPipeMeta() { + return checkPipe; + } + + public void setCoilMeta(HeatingCoilLevel meta) { + checkCoil = meta; + } + + public HeatingCoilLevel getCoilMeta() { + return checkCoil; + } + + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + IStructureElement allCasingsElement = withChannel( + "casing", + ofChain( + IntStream.range(0, 8) + .mapToObj(MTEChemicalPlant::ofSolidCasing) + .collect(Collectors.toList()))); + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape( + mName, + transpose( + new String[][] { + { "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX" }, + { "X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X" }, + { "X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X" }, + { "X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X" }, + { "X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X" }, + { "X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X" }, + { "CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC" }, })) + .addElement( + 'C', + ofChain( + buildHatchAdder(MTEChemicalPlant.class).atLeast(Maintenance) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + buildHatchAdder(MTEChemicalPlant.class).atLeast(InputHatch, OutputHatch, InputBus, OutputBus) + .adder(MTEChemicalPlant::addChemicalPlantList) + .hatchItemFilterAnd( + (t, s) -> filterByMTETier( + Integer.MIN_VALUE, + s.stackSize >= 10 ? Integer.MAX_VALUE : s.stackSize)) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + buildHatchAdder(MTEChemicalPlant.class).hatchClass(MTEHatchCatalysts.class) + .shouldReject(t -> t.mCatalystBuses.size() >= 1) + .adder(MTEChemicalPlant::addChemicalPlantList) + .casingIndex(getCasingTextureID()) + .dot(1) + .build(), + allCasingsElement)) + .addElement('X', allCasingsElement) + .addElement( + 'M', + withChannel( + "machine", + addTieredBlock( + GregTechAPI.sBlockCasings1, + MTEChemicalPlant::setMachineMeta, + MTEChemicalPlant::getMachineMeta, + 10))) + .addElement( + 'H', + withChannel("coil", ofCoil(MTEChemicalPlant::setCoilMeta, MTEChemicalPlant::getCoilMeta))) + .addElement( + 'P', + withChannel( + "pipe", + addTieredBlock( + GregTechAPI.sBlockCasings2, + MTEChemicalPlant::setPipeMeta, + MTEChemicalPlant::getPipeMeta, + 12, + 16))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + private static IStructureElement ofSolidCasing(int aIndex) { + return new IStructureElement() { + + @Override + public boolean check(MTEChemicalPlant t, World world, int x, int y, int z) { + if (check(aIndex, world, x, y, z)) { + t.checkCasing[aIndex]++; + t.mCasing++; + return true; + } else return false; + } + + private boolean check(int aIndex, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block target = mTieredBlockRegistry.get(aIndex) + .getValue_1(); + int targetMeta = mTieredBlockRegistry.get(aIndex) + .getValue_2(); + return target.equals(block) && meta == targetMeta; + } + + int getIndex(int size) { + if (size > 8) size = 8; + return size - 1; + } + + @Override + public boolean spawnHint(MTEChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle( + world, + x, + y, + z, + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_2()); + return true; + } + + @Override + public boolean placeBlock(MTEChemicalPlant t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock( + x, + y, + z, + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_2(), + 3); + } + + @Nullable + @Override + public BlocksToPlace getBlocksToPlace(MTEChemicalPlant gregtechMTE_chemicalPlant, World world, int x, int y, + int z, ItemStack trigger, AutoPlaceEnvironment env) { + return BlocksToPlace.create( + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_2()); + } + + @Override + public PlaceResult survivalPlaceBlock(MTEChemicalPlant t, World world, int x, int y, int z, + ItemStack trigger, AutoPlaceEnvironment env) { + if (check(getIndex(trigger.stackSize), world, x, y, z)) return PlaceResult.SKIP; + return StructureUtility.survivalPlaceBlock( + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_1(), + mTieredBlockRegistry.get(getIndex(trigger.stackSize)) + .getValue_2(), + world, + x, + y, + z, + env.getSource(), + env.getActor(), + env.getChatter()); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 3, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + return survivialBuildPiece(mName, stackSize, 3, 6, 0, elementBudget, env, false, true); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + for (int i = 0; i < 8; i++) { + checkCasing[i] = 0; + } + checkPipe = 0; + checkMachine = 0; + mSolidCasingTier = 0; + mMachineCasingTier = 0; + mPipeCasingTier = 0; + mCoilTier = 0; + maxTierOfHatch = 0; + mCatalystBuses.clear(); + setCoilMeta(HeatingCoilLevel.None); + if (checkPiece(mName, 3, 6, 0) && mCasing >= 70) { + for (int i = 0; i < 8; i++) { + if (checkCasing[i] == mCasing) { + mSolidCasingTier = i; + } else if (checkCasing[i] > 0) return false; + } + mMachineCasingTier = checkMachine - 1; + mPipeCasingTier = checkPipe - 12; + mCoilTier = checkCoil.getTier(); + getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData()); + updateHatchTexture(); + return (mMachineCasingTier >= 9 || mMachineCasingTier >= maxTierOfHatch) && mCatalystBuses.size() <= 1; + } + return false; + } + + public void updateHatchTexture() { + for (MTEHatch h : mCatalystBuses) h.updateTexture(getCasingTextureID()); + for (IDualInputHatch h : mDualInputHatches) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mInputBusses) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + for (MTEHatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + } + + public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchCatalysts) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchInputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((MTEHatchInputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchMaintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchEnergy) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((MTEHatchEnergy) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchOutputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((MTEHatchOutputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchInput) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((MTEHatchInput) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof MTEHatchOutput) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((MTEHatchOutput) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; + } + + @Override + protected IIconContainer getActiveOverlay() { + return TexturesGtBlock.oMCAChemicalPlantActive; + } + + @Override + protected IIconContainer getInactiveOverlay() { + return TexturesGtBlock.oMCAChemicalPlant; + } + + @Override + protected int getCasingTextureId() { + return getCasingTextureID(); + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.chemicalPlantRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + private int getSolidCasingTier() { + return this.mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + + private int getPipeCasingTier() { + return mPipeCasingTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + return getCasingTextureIdForTier(aTier); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTETieredMachineBlock aMachineBlock) { + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + log("Hatch tier too high."); + return false; + } else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } else { + log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchCatalysts) { + log("Found GT_MetaTileEntity_Hatch_Catalysts"); + return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public int getMaxCatalystDurability() { + return 50; + } + + @Override + public byte getUpdateData() { + return (byte) mSolidCasingTier; + } + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) { + super.receiveClientEvent(aEventID, aValue); + if (aEventID == GregTechTileClientEvents.CHANGE_CUSTOM_DATA && (aValue & 0x80) == 0) { + // received an update data from above method + // if no &0x80 clause it might catch the noop texture page event + mSolidCasingTier = aValue; + } + } + + private void damageCatalyst(@Nonnull ItemStack aStack, int minParallel) { + // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. + if (!isCatalystDamageable()) return; + for (int i = 0; i < minParallel; i++) { + if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { + int damage = getDamage(aStack) + 1; + if (damage >= getMaxCatalystDurability()) { + addOutput(CI.getEmptyCatalyst(1)); + aStack.stackSize -= 1; + return; + } else { + setDamage(aStack, damage); + } + } + } + } + + private boolean isCatalystDamageable() { + return this.mCoilTier < 10 || this.mPipeCasingTier < 4; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + ItemStack catalyst; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (recipe.mSpecialValue > mSolidCasingTier) { + return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue + 1); + } + // checks if it has a catalyst + ItemStack catalystInRecipe = null; + for (ItemStack item : recipe.mInputs) { + if (ItemUtils.isCatalyst(item)) { + catalystInRecipe = item; + break; + } + } + + if (catalystInRecipe != null) { + catalyst = findCatalyst(getCatalystInputs().toArray(new ItemStack[0]), catalystInRecipe); + if (catalyst == null) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); + } + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + public CheckRecipeResult process() { + ArrayList inputItemsList = new ArrayList<>(Arrays.asList(inputItems)); + inputItemsList.addAll(getCatalystInputs()); + inputItems = inputItemsList.toArray(new ItemStack[0]); + return super.process(); + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { + if (catalyst != null) { + damageCatalyst(catalyst, getCurrentParallels()); + } + return super.onRecipeStart(recipe); + } + }.setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + // Same speed bonus as pyro oven + logic.setSpeedBonus(2F / (1 + this.mCoilTier)); + } + + @Override + public void updateSlots() { + super.updateSlots(); + for (MTEHatchCatalysts h : mCatalystBuses) { + h.updateSlots(); + h.tryFillUsageSlots(); + } + } + + private ItemStack findCatalyst(ItemStack[] aItemInputs, ItemStack catalyst) { + if (aItemInputs != null) { + for (ItemStack item : aItemInputs) { + if (GTUtility.areStacksEqual(item, catalyst, true)) { + return item; + } + } + } + return null; + } + + private int getDamage(@Nonnull ItemStack aStack) { + return ItemGenericChemBase.getCatalystDamage(aStack); + } + + private void setDamage(@Nonnull ItemStack aStack, int aAmount) { + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); + } + + /* + * Catalyst Handling + */ + public ArrayList getCatalystInputs() { + ArrayList tItems = new ArrayList<>(); + for (MTEHatchCatalysts tHatch : filterValidMTEs(mCatalystBuses)) { + AutoMap aHatchContent = tHatch.getContentUsageSlots(); + if (!aHatchContent.isEmpty()) { + tItems.addAll(aHatchContent); + } + } + return tItems; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java deleted file mode 100644 index 2e3370fe4c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java +++ /dev/null @@ -1,497 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.mega; - -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.withChannel; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.ExoticEnergy; -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.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.List; - -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 org.jetbrains.annotations.NotNull; - -import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; -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 gregtech.api.enums.GT_Values; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.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; -import gtPlusPlus.api.recipe.GTPPRecipeMaps; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregTechMetaTileEntity_MegaAlloyBlastSmelter - extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase - implements ISurvivalConstructable { - - private static final int MAX_PARALLELS = 256; - private HeatingCoilLevel coilLevel; - private byte glassTier = -1; - private float speedBonus = 1; - private float energyDiscount = 1; - private boolean hasNormalCoils; - - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition - .builder() - .addShape( - "main", - new String[][] { - { " ", " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", " ", - " ", " DDDDD ", " CCCCC ", " AEEEA ", " AE~EA ", " AEEEA ", - " CCCCC ", " ZZZZZ " }, - { " DDDDD ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", - " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", - " DDDDD ", " D D ", " C C ", " A A ", " A A ", " A A ", - " C C ", " ZZZZZZZ " }, - { " DDDDDDD ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", - " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", - " DBBBBBD ", " D BBBBB D ", " C BBBBB C ", " A BBBBB A ", " A BBBBB A ", " A BBBBB A ", - " C BBBBB C ", " ZZZZZZZZZ " }, - { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", - "C B B C", "ZZZZZZZZZZZ" }, - { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", - "C B B C", "ZZZZZZZZZZZ" }, - { " DDDDFDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", - "C B B C", "ZZZZZZZZZZZ" }, - { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", - "C B B C", "ZZZZZZZZZZZ" }, - { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", - " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", - "C B B C", "ZZZZZZZZZZZ" }, - { " DDDDDDD ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", - " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", - " DBBBBBD ", " D BBBBB D ", " C BBBBB C ", " A BBBBB A ", " A BBBBB A ", " A BBBBB A ", - " C BBBBB C ", " ZZZZZZZZZ " }, - { " DDDDD ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", - " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", - " DDDDD ", " D D ", " C C ", " A A ", " A A ", " A A ", - " C C ", " ZZZZZZZ " }, - { " ", " ", " ", " ", " ", " ", - " ", " ", " ", " ", " ", " ", - " ", " DDDDD ", " CCCCC ", " AAAAA ", " AAAAA ", " AAAAA ", - " CCCCC ", " ZZZZZ " } }) - .addElement( - 'B', - withChannel( - "coil", - ofChain( - onElementPass( - te -> te.hasNormalCoils = false, - ofCoil( - GregTechMetaTileEntity_MegaAlloyBlastSmelter::setCoilLevel, - GregTechMetaTileEntity_MegaAlloyBlastSmelter::getCoilLevel)), - onElementPass(te -> te.hasNormalCoils = true, ofBlock(ModBlocks.blockCasingsMisc, 14))))) - - .addElement( - 'Z', - buildHatchAdder(GregTechMetaTileEntity_MegaAlloyBlastSmelter.class) - .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Energy, ExoticEnergy) - .casingIndex(TAE.GTPP_INDEX(15)) - .dot(1) - .buildAndChain(ofBlock(ModBlocks.blockCasingsMisc, 15))) - .addElement( - 'E', - buildHatchAdder(GregTechMetaTileEntity_MegaAlloyBlastSmelter.class).atLeast(Maintenance) - .casingIndex(TAE.GTPP_INDEX(15)) - .dot(2) - .buildAndChain(ofBlock(ModBlocks.blockCasingsMisc, 15))) - .addElement('D', ofBlock(ModBlocks.blockCasingsMisc, 15)) - .addElement('C', ofBlock(ModBlocks.blockCasingsMisc, 14)) - .addElement( - 'A', - withChannel( - "glass", - BorosilicateGlass.ofBoroGlass((byte) -1, (te, t) -> te.glassTier = t, te -> te.glassTier))) - .addElement('F', Muffler.newAny(TAE.GTPP_INDEX(15), 3)) - .build(); - - public GregTechMetaTileEntity_MegaAlloyBlastSmelter(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregTechMetaTileEntity_MegaAlloyBlastSmelter(String aName) { - super(aName); - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic() { - - @NotNull - @Override - protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (glassTier < GT_Utility.getTier(recipe.mEUt)) { - return CheckRecipeResultRegistry.insufficientMachineTier(GT_Utility.getTier(recipe.mEUt)); - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - @NotNull - @Override - protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { - calculateEnergyDiscount(coilLevel, recipe); - return super.createOverclockCalculator(recipe).setSpeedBoost(speedBonus) - .setEUtDiscount(energyDiscount); - } - }.setMaxParallel(MAX_PARALLELS); - } - - @Override - protected void setProcessingLogicPower(ProcessingLogic logic) { - logic.setAvailableVoltage(getMaxInputEu()); - logic.setAvailableAmperage(1); - } - - @Override - public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - boolean exotic = addExoticEnergyInputToMachineList(aTileEntity, aBaseCasingIndex); - return super.addToMachineList(aTileEntity, aBaseCasingIndex) || exotic; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - glassTier = -1; - coilLevel = HeatingCoilLevel.None; - if (!checkPiece("main", 5, 16, 0)) return false; - if (hasNormalCoils) coilLevel = HeatingCoilLevel.None; - if (mMaintenanceHatches.size() != 1) return false; - if (mMufflerHatches.size() != 1) return false; - if (this.glassTier < 10 && !getExoticAndNormalEnergyHatchList().isEmpty()) { - for (GT_MetaTileEntity_Hatch hatchEnergy : getExoticAndNormalEnergyHatchList()) { - if (this.glassTier < hatchEnergy.mTier) { - return false; - } - } - } - // Disallow lasers if the glass is below UV tier - if (glassTier < 8) { - for (GT_MetaTileEntity_Hatch hatchEnergy : getExoticEnergyHatches()) { - if (hatchEnergy.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { - return false; - } - } - } - calculateSpeedBonus(coilLevel, glassTier); - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - private void calculateSpeedBonus(HeatingCoilLevel lvl, int glassTier) { - int bonusTier = lvl != null ? Math.min(lvl.getTier() - 3, glassTier - 2) : 0; - if (bonusTier < 0) { - speedBonus = 1; - return; - } - speedBonus = 1 - 0.05f * bonusTier; - } - - private void calculateEnergyDiscount(HeatingCoilLevel lvl, GT_Recipe recipe) { - int recipeTier = GT_Utility.getTier(recipe.mEUt); - int tierDifference = lvl != null ? lvl.getTier() + 1 - recipeTier : 0; - if (tierDifference < 0) { - energyDiscount = 1; - return; - } - energyDiscount = (float) Math.pow(0.95, tierDifference); - } - - @Override - public void explodeMultiblock() { - super.explodeMultiblock(); - } - - @Override - public List getExoticAndNormalEnergyHatchList() { - List tHatches = new ArrayList<>(); - tHatches.addAll(mExoticEnergyHatches); - tHatches.addAll(mEnergyHatches); - return tHatches; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece("main", stackSize, hintsOnly, 5, 16, 0); - } - - @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("Fluid Alloy Cooker") - .addInfo("Controller block for the Mega Alloy Blast Smelter") - .addInfo( - "Runs the same recipes as the normal ABS, except with up to " + EnumChatFormatting.BOLD - + EnumChatFormatting.UNDERLINE - + MAX_PARALLELS - + EnumChatFormatting.RESET - + EnumChatFormatting.GRAY - + " parallels.") - .addInfo( - "Every coil tier above TPV grants a speed bonus if the equivalent or better glass tier is present.") - .addInfo( - EnumChatFormatting.YELLOW + "Speed Bonus" - + EnumChatFormatting.GRAY - + ": 5% lower recipe time per tier (additive)") - .addInfo("Furthermore, an energy discount is granted for using coils above the recipe tier.") - .addInfo( - EnumChatFormatting.YELLOW + "Energy Discount" - + EnumChatFormatting.GRAY - + ": 5% lower energy consumption per tier (multiplicative)") - .addInfo( - EnumChatFormatting.ITALIC - + "Can also use normal ABS coils in their place instead, if you don't like the bonuses :)" - + EnumChatFormatting.RESET - + EnumChatFormatting.GRAY) - .addInfo("The glass limits the tier of the energy hatch. UEV glass unlocks all tiers.") - .addInfo("UV glass required for TecTech laser hatches.") - .addInfo( - EnumChatFormatting.ITALIC + "\"all it does is make metals hot\"" - + EnumChatFormatting.RESET - + EnumChatFormatting.GRAY) - .beginStructureBlock(11, 20, 11, false) - .addStructureInfo("This structure is too complex! See schematic for details.") - .addMaintenanceHatch("Around the controller", 2) - .addOtherStructurePart("Input Bus, Output Bus, Input Hatch, Output Bus, Energy Hatch", "Bottom Casing", 1) - .addMufflerHatch("1 in the center of the top layer", 3) - .toolTipFinisher( - EnumChatFormatting.AQUA + "MadMan310 " - + EnumChatFormatting.GRAY - + "via " - + EnumChatFormatting.RED - + "GT++"); - return tt; - } - - @Override - public String[] getInfoData() { - long storedEnergy = 0; - long maxEnergy = 0; - int paras = getBaseMetaTileEntity().isActive() ? processingLogic.getCurrentParallels() : 0; - int moreSpeed = (int) ((1 - speedBonus) * 100); - int lessEnergy = (int) ((1 - energyDiscount) * 100); - for (GT_MetaTileEntity_Hatch tHatch : filterValidMTEs(mExoticEnergyHatches)) { - storedEnergy += tHatch.getBaseMetaTileEntity() - .getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity() - .getEUCapacity(); - } - - return new String[] { "------------ Critical Information ------------", - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(mProgresstime) - + EnumChatFormatting.RESET - + "t / " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(mMaxProgresstime) - + EnumChatFormatting.RESET - + "t", - 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(-lEUt) - + EnumChatFormatting.RESET - + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(getAverageInputVoltage()) - + EnumChatFormatting.RESET - + " EU/t(*" - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(getMaxInputAmps()) - + EnumChatFormatting.RESET - + "A) " - + StatCollector.translateToLocal("GT5U.machines.tier") - + ": " - + EnumChatFormatting.YELLOW - + GT_Values.VN[GT_Utility.getTier(getAverageInputVoltage())] - + EnumChatFormatting.RESET, - "Parallels: " + EnumChatFormatting.BLUE + paras + EnumChatFormatting.RESET, - "Speed Bonus: " + EnumChatFormatting.BLUE + moreSpeed + "%" + EnumChatFormatting.RESET, - "Energy Discount: " + EnumChatFormatting.BLUE + lessEnergy + "%" + EnumChatFormatting.RESET, - "-----------------------------------------" }; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregTechMetaTileEntity_MegaAlloyBlastSmelter(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(TAE.GTPP_INDEX(15)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCAMegaAlloyBlastSmelterActive) - .extFacing() - .build() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)), - TextureFactory.builder() - .addIcon(TexturesGtBlock.oMCAMegaAlloyBlastSmelter) - .extFacing() - .build() }; - } - return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)) }; - } - - @Override - public RecipeMap getRecipeMap() { - return GTPPRecipeMaps.alloyBlastSmelterRecipes; - } - - public HeatingCoilLevel getCoilLevel() { - return coilLevel; - } - - public void setCoilLevel(HeatingCoilLevel coilLevel) { - this.coilLevel = coilLevel; - } - - @Override - public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) { - // Lock to single recipe - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } else { - 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, ItemStack aTool) { - if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { - GT_Utility.sendChatToPlayer(aPlayer, "Batch recipes."); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Don't batch recipes."); - } - } - - return true; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 102400; - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - return survivialBuildPiece("main", stackSize, 5, 16, 0, elementBudget, env, false, true); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.glassTier = aNBT.getByte("glassTier"); - if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - inputSeparation = aNBT.getBoolean("separateBusses"); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("glassTier", glassTier); - super.saveNBTData(aNBT); - } - - @Override - public boolean supportsInputSeparation() { - return true; - } - - @Override - public boolean supportsVoidProtection() { - return true; - } - - @Override - public boolean supportsBatchMode() { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/MTEMegaAlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/MTEMegaAlloyBlastSmelter.java new file mode 100644 index 0000000000..1f97f38402 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/MTEMegaAlloyBlastSmelter.java @@ -0,0 +1,494 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.mega; + +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.withChannel; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.ExoticEnergy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.List; + +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 org.jetbrains.annotations.NotNull; + +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 bartworks.API.BorosilicateGlass; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +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.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEMegaAlloyBlastSmelter extends MTEExtendedPowerMultiBlockBase + implements ISurvivalConstructable { + + private static final int MAX_PARALLELS = 256; + private HeatingCoilLevel coilLevel; + private byte glassTier = -1; + private float speedBonus = 1; + private float energyDiscount = 1; + private boolean hasNormalCoils; + + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + "main", + new String[][] { + { " ", " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", " ", + " ", " DDDDD ", " CCCCC ", " AEEEA ", " AE~EA ", " AEEEA ", + " CCCCC ", " ZZZZZ " }, + { " DDDDD ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", + " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", + " DDDDD ", " D D ", " C C ", " A A ", " A A ", " A A ", + " C C ", " ZZZZZZZ " }, + { " DDDDDDD ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", + " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", + " DBBBBBD ", " D BBBBB D ", " C BBBBB C ", " A BBBBB A ", " A BBBBB A ", " A BBBBB A ", + " C BBBBB C ", " ZZZZZZZZZ " }, + { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", + "C B B C", "ZZZZZZZZZZZ" }, + { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", + "C B B C", "ZZZZZZZZZZZ" }, + { " DDDDFDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", + "C B B C", "ZZZZZZZZZZZ" }, + { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", + "C B B C", "ZZZZZZZZZZZ" }, + { " DDDDDDDDD ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", " AB BA ", + " DB BD ", "D B B D", "C B B C", "A B B A", "A B B A", "A B B A", + "C B B C", "ZZZZZZZZZZZ" }, + { " DDDDDDD ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", + " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", " ABBBBBA ", + " DBBBBBD ", " D BBBBB D ", " C BBBBB C ", " A BBBBB A ", " A BBBBB A ", " A BBBBB A ", + " C BBBBB C ", " ZZZZZZZZZ " }, + { " DDDDD ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", + " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", " AAAAA ", + " DDDDD ", " D D ", " C C ", " A A ", " A A ", " A A ", + " C C ", " ZZZZZZZ " }, + { " ", " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", " ", + " ", " DDDDD ", " CCCCC ", " AAAAA ", " AAAAA ", " AAAAA ", + " CCCCC ", " ZZZZZ " } }) + .addElement( + 'B', + withChannel( + "coil", + ofChain( + onElementPass( + te -> te.hasNormalCoils = false, + ofCoil(MTEMegaAlloyBlastSmelter::setCoilLevel, MTEMegaAlloyBlastSmelter::getCoilLevel)), + onElementPass(te -> te.hasNormalCoils = true, ofBlock(ModBlocks.blockCasingsMisc, 14))))) + + .addElement( + 'Z', + buildHatchAdder(MTEMegaAlloyBlastSmelter.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Energy, ExoticEnergy) + .casingIndex(TAE.GTPP_INDEX(15)) + .dot(1) + .buildAndChain(ofBlock(ModBlocks.blockCasingsMisc, 15))) + .addElement( + 'E', + buildHatchAdder(MTEMegaAlloyBlastSmelter.class).atLeast(Maintenance) + .casingIndex(TAE.GTPP_INDEX(15)) + .dot(2) + .buildAndChain(ofBlock(ModBlocks.blockCasingsMisc, 15))) + .addElement('D', ofBlock(ModBlocks.blockCasingsMisc, 15)) + .addElement('C', ofBlock(ModBlocks.blockCasingsMisc, 14)) + .addElement( + 'A', + withChannel( + "glass", + BorosilicateGlass.ofBoroGlass((byte) -1, (te, t) -> te.glassTier = t, te -> te.glassTier))) + .addElement('F', Muffler.newAny(TAE.GTPP_INDEX(15), 3)) + .build(); + + public MTEMegaAlloyBlastSmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMegaAlloyBlastSmelter(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (glassTier < GTUtility.getTier(recipe.mEUt)) { + return CheckRecipeResultRegistry.insufficientMachineTier(GTUtility.getTier(recipe.mEUt)); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + calculateEnergyDiscount(coilLevel, recipe); + return super.createOverclockCalculator(recipe).setSpeedBoost(speedBonus) + .setEUtDiscount(energyDiscount); + } + }.setMaxParallel(MAX_PARALLELS); + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(getMaxInputEu()); + logic.setAvailableAmperage(1); + } + + @Override + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + boolean exotic = addExoticEnergyInputToMachineList(aTileEntity, aBaseCasingIndex); + return super.addToMachineList(aTileEntity, aBaseCasingIndex) || exotic; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + glassTier = -1; + coilLevel = HeatingCoilLevel.None; + if (!checkPiece("main", 5, 16, 0)) return false; + if (hasNormalCoils) coilLevel = HeatingCoilLevel.None; + if (mMaintenanceHatches.size() != 1) return false; + if (mMufflerHatches.size() != 1) return false; + if (this.glassTier < 10 && !getExoticAndNormalEnergyHatchList().isEmpty()) { + for (MTEHatch hatchEnergy : getExoticAndNormalEnergyHatchList()) { + if (this.glassTier < hatchEnergy.mTier) { + return false; + } + } + } + // Disallow lasers if the glass is below UV tier + if (glassTier < 8) { + for (MTEHatch hatchEnergy : getExoticEnergyHatches()) { + if (hatchEnergy.getConnectionType() == MTEHatch.ConnectionType.LASER) { + return false; + } + } + } + calculateSpeedBonus(coilLevel, glassTier); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + private void calculateSpeedBonus(HeatingCoilLevel lvl, int glassTier) { + int bonusTier = lvl != null ? Math.min(lvl.getTier() - 3, glassTier - 2) : 0; + if (bonusTier < 0) { + speedBonus = 1; + return; + } + speedBonus = 1 - 0.05f * bonusTier; + } + + private void calculateEnergyDiscount(HeatingCoilLevel lvl, GTRecipe recipe) { + int recipeTier = GTUtility.getTier(recipe.mEUt); + int tierDifference = lvl != null ? lvl.getTier() + 1 - recipeTier : 0; + if (tierDifference < 0) { + energyDiscount = 1; + return; + } + energyDiscount = (float) Math.pow(0.95, tierDifference); + } + + @Override + public void explodeMultiblock() { + super.explodeMultiblock(); + } + + @Override + public List getExoticAndNormalEnergyHatchList() { + List tHatches = new ArrayList<>(); + tHatches.addAll(mExoticEnergyHatches); + tHatches.addAll(mEnergyHatches); + return tHatches; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece("main", stackSize, hintsOnly, 5, 16, 0); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Fluid Alloy Cooker") + .addInfo("Controller block for the Mega Alloy Blast Smelter") + .addInfo( + "Runs the same recipes as the normal ABS, except with up to " + EnumChatFormatting.BOLD + + EnumChatFormatting.UNDERLINE + + MAX_PARALLELS + + EnumChatFormatting.RESET + + EnumChatFormatting.GRAY + + " parallels.") + .addInfo( + "Every coil tier above TPV grants a speed bonus if the equivalent or better glass tier is present.") + .addInfo( + EnumChatFormatting.YELLOW + "Speed Bonus" + + EnumChatFormatting.GRAY + + ": 5% lower recipe time per tier (additive)") + .addInfo("Furthermore, an energy discount is granted for using coils above the recipe tier.") + .addInfo( + EnumChatFormatting.YELLOW + "Energy Discount" + + EnumChatFormatting.GRAY + + ": 5% lower energy consumption per tier (multiplicative)") + .addInfo( + EnumChatFormatting.ITALIC + + "Can also use normal ABS coils in their place instead, if you don't like the bonuses :)" + + EnumChatFormatting.RESET + + EnumChatFormatting.GRAY) + .addInfo("The glass limits the tier of the energy hatch. UEV glass unlocks all tiers.") + .addInfo("UV glass required for TecTech laser hatches.") + .addInfo( + EnumChatFormatting.ITALIC + "\"all it does is make metals hot\"" + + EnumChatFormatting.RESET + + EnumChatFormatting.GRAY) + .beginStructureBlock(11, 20, 11, false) + .addStructureInfo("This structure is too complex! See schematic for details.") + .addMaintenanceHatch("Around the controller", 2) + .addOtherStructurePart("Input Bus, Output Bus, Input Hatch, Output Bus, Energy Hatch", "Bottom Casing", 1) + .addMufflerHatch("1 in the center of the top layer", 3) + .toolTipFinisher( + EnumChatFormatting.AQUA + "MadMan310 " + + EnumChatFormatting.GRAY + + "via " + + EnumChatFormatting.RED + + "GT++"); + return tt; + } + + @Override + public String[] getInfoData() { + long storedEnergy = 0; + long maxEnergy = 0; + int paras = getBaseMetaTileEntity().isActive() ? processingLogic.getCurrentParallels() : 0; + int moreSpeed = (int) ((1 - speedBonus) * 100); + int lessEnergy = (int) ((1 - energyDiscount) * 100); + for (MTEHatch tHatch : filterValidMTEs(mExoticEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + return new String[] { "------------ Critical Information ------------", + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(mProgresstime) + + EnumChatFormatting.RESET + + "t / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(mMaxProgresstime) + + EnumChatFormatting.RESET + + "t", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + + EnumChatFormatting.RED + + GTUtility.formatNumbers(-lEUt) + + EnumChatFormatting.RESET + + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(getAverageInputVoltage()) + + EnumChatFormatting.RESET + + " EU/t(*" + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(getMaxInputAmps()) + + EnumChatFormatting.RESET + + "A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + + ": " + + EnumChatFormatting.YELLOW + + GTValues.VN[GTUtility.getTier(getAverageInputVoltage())] + + EnumChatFormatting.RESET, + "Parallels: " + EnumChatFormatting.BLUE + paras + EnumChatFormatting.RESET, + "Speed Bonus: " + EnumChatFormatting.BLUE + moreSpeed + "%" + EnumChatFormatting.RESET, + "Energy Discount: " + EnumChatFormatting.BLUE + lessEnergy + "%" + EnumChatFormatting.RESET, + "-----------------------------------------" }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMegaAlloyBlastSmelter(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(TAE.GTPP_INDEX(15)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCAMegaAlloyBlastSmelterActive) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)), + TextureFactory.builder() + .addIcon(TexturesGtBlock.oMCAMegaAlloyBlastSmelter) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)) }; + } + + @Override + public RecipeMap getRecipeMap() { + return GTPPRecipeMaps.alloyBlastSmelterRecipes; + } + + public HeatingCoilLevel getCoilLevel() { + return coilLevel; + } + + public void setCoilLevel(HeatingCoilLevel coilLevel) { + this.coilLevel = coilLevel; + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + // Lock to single recipe + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } else { + inputSeparation = !inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ, ItemStack aTool) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GTUtility.sendChatToPlayer(aPlayer, "Batch recipes."); + } else { + GTUtility.sendChatToPlayer(aPlayer, "Don't batch recipes."); + } + } + + return true; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 102400; + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + return survivialBuildPiece("main", stackSize, 5, 16, 0, elementBudget, env, false, true); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.glassTier = aNBT.getByte("glassTier"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("separateBusses"); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("glassTier", glassTier); + super.saveNBTData(aNBT); + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java deleted file mode 100644 index 84fac40265..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java +++ /dev/null @@ -1,208 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import static gtPlusPlus.core.lib.CORE.RANDOM; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -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.objects.GT_RenderedTexture; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.SimpleCheckRecipeResult; -import gregtech.api.recipe.maps.FuelBackend; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("deprecation") -public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbineBase { - - private static final HashSet BLACKLIST = new HashSet<>(); - - static { - BLACKLIST.add( - Materials.Benzene.getFluid(0) - .getFluid()); - } - - public GT_MTE_LargeTurbine_Gas(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MTE_LargeTurbine_Gas(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_LargeTurbine_Gas(mName); - } - - @Override - public int getCasingMeta() { - return 3; - } - - @Override - public int getCasingTextureIndex() { - return 58; - } - - @Override - protected boolean requiresOutputHatch() { - return false; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 4000; - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null) { - return 0; - } - GT_Recipe tFuel = getRecipeMap().getBackend() - .findFuel(aLiquid); - if (tFuel != null) { - return tFuel.mSpecialValue; - } - return 0; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.gasTurbineFuels; - } - - @Override - public int getRecipeCatalystPriority() { - return -20; - } - - @Override - protected boolean filtersFluid() { - return false; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - List fluids = getStoredFluids(); - for (FluidStack fluid : fluids) { - if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { - return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); - } - } - return super.checkProcessing(); - } - - @Override - long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (aFluids.size() >= 1) { - int tEU = 0; - int actualOptimalFlow = 0; - FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. - // Doesn't matter which one. Ignore the rest! - int fuelValue = getFuelValue(firstFuelType); - // log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu"); - if (aOptFlow < fuelValue) { - // turbine too weak and/or fuel too powerful - // at least consume 1L - this.realOptFlow = 1; - // wastes the extra fuel and generate aOptFlow directly - depleteInput(new FluidStack(firstFuelType, 1)); - this.storedFluid += 1; - return GT_Utility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); - } - - actualOptimalFlow = GT_Utility.safeInt((long) (aOptFlow * (double) flowMultipliers[1] / fuelValue)); - this.realOptFlow = actualOptimalFlow; - - int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of - // optimal flow. Variable - // required outside of loop for - // multi-hatch scenarios. - int flow = 0; - int totalFlow = 0; - - storedFluid = 0; - for (FluidStack aFluid : aFluids) { - if (aFluid.isFluidEqual(firstFuelType)) { - flow = Math.min(aFluid.amount, remainingFlow); // try to use up to 125% of optimal flow w/o - // exceeding remainingFlow - depleteInput(new FluidStack(aFluid, flow)); // deplete that amount - this.storedFluid += aFluid.amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - } - } - if (totalFlow <= 0) return 0; - tEU = GT_Utility.safeInt((long) totalFlow * fuelValue); - - if (totalFlow == actualOptimalFlow) { - tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); - } else { - float efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); - tEU *= efficiency; - tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); - } - - return tEU; - } - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return (RANDOM.nextInt(4) == 0) ? 0 : 1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public String getMachineType() { - return "Large Gas Turbine"; - } - - @Override - protected String getTurbineType() { - return "Gas"; - } - - @Override - protected String getCasingName() { - return "Reinforced Gas Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java deleted file mode 100644 index db99b52be1..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ /dev/null @@ -1,314 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import java.util.ArrayList; -import java.util.HashSet; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.objects.GT_RenderedTexture; -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.recipe.maps.FuelBackend; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("deprecation") -public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTurbineBase { - - private static final HashSet BLACKLIST = new HashSet<>(); - - public GT_MTE_LargeTurbine_Plasma(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MTE_LargeTurbine_Plasma(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_LargeTurbine_Plasma(mName); - } - - @Override - public int getCasingMeta() { - return 4; - } - - @Override - public int getCasingTextureIndex() { - return 60; - } - - @Override - protected boolean requiresOutputHatch() { - return true; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 0; - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null) { - return 0; - } - GT_Recipe tFuel = getRecipeMap().getBackend() - .findFuel(aLiquid); - if (tFuel != null) { - return tFuel.mSpecialValue; - } - return 0; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.plasmaFuels; - } - - @Override - public int getRecipeCatalystPriority() { - return -20; - } - - @Override - protected boolean filtersFluid() { - return false; - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - - try { - ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { - hatch: for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - ArrayList aTurbines = getAllBufferedTurbines(); - for (ItemStack aTurbineItem : aTurbines) { - if (aTurbineItem == null) { - continue; - } - if (aHatch.insertTurbine(aTurbineItem.copy())) { - depleteTurbineFromStock(aTurbineItem); - continue hatch; - } - } - } - } - - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - stopMachine(ShutDownReasonRegistry.NO_TURBINE); - return CheckRecipeResultRegistry.NO_TURBINE_FOUND; - } - - ArrayList tFluids = getStoredFluids(); - - if (tFluids.size() > 0) { - for (FluidStack fluid : tFluids) { - if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { - return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); - } - } - if (baseEff == 0 || optFlow == 0 - || counter >= 512 - || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity() - .hasInventoryBeenModified()) { - counter = 0; - - float aTotalBaseEff = 0; - float aTotalOptimalFlow = 0; - - ItemStack aStack = getFullTurbineAssemblies().get(0) - .getTurbine(); - aTotalBaseEff += GT_Utility.safeInt( - (long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - aTotalOptimalFlow += GT_Utility.safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack) - .getSpeedMultiplier() * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); - - // Calculate total EU/t (as shown on turbine tooltip (Fast mode doesn't affect)) - double aEUPerTurbine = aTotalOptimalFlow * 40 - * 0.0105 - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mPlasmaMultiplier - * (50.0f + (10.0f * ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack))); - aTotalOptimalFlow *= getSpeedMultiplier(); - - if (aTotalOptimalFlow < 0) { - aTotalOptimalFlow = 100; - } - - flowMultipliers[0] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mSteamMultiplier; - flowMultipliers[1] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mGasMultiplier; - flowMultipliers[2] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mPlasmaMultiplier; - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); - euPerTurbine = MathUtils.roundToClosestInt(aEUPerTurbine); - if (optFlow <= 0 || baseEff <= 0) { - stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - } else { - counter++; - } - } - - // How much the turbine should be producing with this flow - long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); - - // Reduce produced power depending on the ratio between fuel value and turbine EU/t with the following - // formula: - // EU/t = EU/t * MIN(1, ( ( (FuelValue / 200) ^ 2 ) / EUPerTurbine)) - int fuelValue = 0; - if (tFluids.size() > 0) { - fuelValue = getFuelValue(new FluidStack(tFluids.get(0), 0)); - } - float magicValue = (fuelValue * 0.005f) * (fuelValue * 0.005f); - float efficiencyLoss = Math.min(1.0f, magicValue / euPerTurbine); - newPower *= efficiencyLoss; - - long difference = newPower - this.lEUt; // difference between current output and new output - - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the - // difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long) Math.abs(difference) / 100)); - - if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed - // change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.lEUt += change; // Apply the change - } else { - this.lEUt = newPower; - } - if (this.lEUt <= 0) { - this.lEUt = 0; - this.mEfficiency = 0; - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } else { - this.mMaxProgresstime = 20; - this.mEfficiencyIncrease = 10; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - // Play sounds (GT++ addition - GT multiblocks play no sounds) - enableAllTurbineHatches(); - return CheckRecipeResultRegistry.GENERATING; - } - } catch (Throwable t) { - t.printStackTrace(); - } - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - - @Override - long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (aFluids.size() >= 1) { - aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks - int tEU = 0; - - int actualOptimalFlow = 0; - - FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. - // Doesn't matter which one. Ignore the rest! - int fuelValue = getFuelValue(firstFuelType); - actualOptimalFlow = GT_Utility - .safeInt((long) Math.ceil((double) aOptFlow * (double) flowMultipliers[2] / (double) fuelValue)); - this.realOptFlow = actualOptimalFlow; // For scanner info - - int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of - // optimal flow. Variable - // required outside of loop for - // multi-hatch scenarios. - int flow = 0; - int totalFlow = 0; - - storedFluid = 0; - for (FluidStack aFluid : aFluids) { - if (aFluid.isFluidEqual(firstFuelType)) { - flow = Math.min(aFluid.amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluid, flow)); // deplete that amount - this.storedFluid += aFluid.amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - } - } - String fn = FluidRegistry.getFluidName(firstFuelType); - String[] nameSegments = fn.split("\\.", 2); - if (nameSegments.length == 2) { - String outputName = nameSegments[1]; - FluidStack output = FluidRegistry.getFluidStack(outputName, totalFlow); - if (output == null) { - output = FluidRegistry.getFluidStack("molten." + outputName, totalFlow); - } - if (output != null) { - addOutput(output); - } - } - if (totalFlow <= 0) return 0; - tEU = GT_Utility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow)); - - if (totalFlow == actualOptimalFlow) { - tEU = GT_Utility.safeInt((long) (aBaseEff / 10000D * tEU)); - } else { - double efficiency = 1.0D - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); - - tEU = (int) (tEU * efficiency); - tEU = GT_Utility.safeInt((long) (aBaseEff / 10000D * tEU)); - } - - return tEU; - } - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - @Override - public String getMachineType() { - return "Large Plasma Turbine"; - } - - @Override - protected String getTurbineType() { - return "Plasma"; - } - - @Override - protected String getCasingName() { - return "Reinforced Plasma Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java deleted file mode 100644 index 6c3db51577..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java +++ /dev/null @@ -1,126 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import java.util.ArrayList; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT_MTE_LargeTurbine_SCSteam extends GregtechMetaTileEntity_LargerTurbineBase { - - public GT_MTE_LargeTurbine_SCSteam(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MTE_LargeTurbine_SCSteam(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_LargeTurbine_SCSteam(mName); - } - - @Override - public int getCasingMeta() { - return 15; - } - - @Override - public int getCasingTextureIndex() { - return 1538; - } - - @Override - protected boolean requiresOutputHatch() { - return true; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 0; - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - return 0; - } - - @Override - long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - int tEU = 0; - int totalFlow = 0; // Byproducts are based on actual flow - int flow = 0; - // Variable required outside of loop for - // multi-hatch scenarios. - this.realOptFlow = aOptFlow; - // this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; - // Will there be an multiplier for SC? - int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to - // 125% of optimal flow. - - storedFluid = 0; - FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1); - for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { - if (GT_Utility.areFluidsEqual(aFluids.get(i), tSCSteam, true)) { - flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount - this.storedFluid += aFluids.get(i).amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - } - } - if (totalFlow <= 0) return 0; - tEU = totalFlow; - addOutput(GT_ModHandler.getSteam(totalFlow * 100)); - if (totalFlow != realOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); - // if(totalFlow>aOptFlow){efficiency = 1.0f;} - tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); - } else { - tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); - } - - return tEU * 100L; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 8; - } - - @Override - public String getMachineType() { - return "Large Supercritical Steam Turbine"; - } - - @Override - protected String getTurbineType() { - return "Supercritical Steam"; - } - - @Override - protected String getCasingName() { - return "Reinforced SC Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return TextureFactory.of(TexturesGtBlock.Overlay_Machine_Controller_Advanced); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return TextureFactory.of(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java deleted file mode 100644 index d1346d3a51..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ /dev/null @@ -1,204 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import java.util.ArrayList; - -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.FluidStack; - -import gregtech.GT_Mod; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("deprecation") -public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTurbineBase { - - public boolean achievement = false; - private boolean looseFit = false; - - public GT_MTE_LargeTurbine_SHSteam(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MTE_LargeTurbine_SHSteam(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_LargeTurbine_SHSteam(mName); - } - - @Override - public int getCasingMeta() { - return 2; - } - - @Override - public int getCasingTextureIndex() { - return 59; - } - - @Override - protected boolean requiresOutputHatch() { - return true; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 0; - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - return 0; - } - - @Override - long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (looseFit) { - aOptFlow *= 4; - if (aBaseEff > 10000) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff = 7500; - } else if (aBaseEff > 7500) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff *= 0.75f; - } else { - aBaseEff *= 0.75f; - } - } - // prevent overflow like that in SC Steam - long tEU = 0; - int totalFlow = 0; // Byproducts are based on actual flow - int flow = 0; - - // Variable required outside of loop for - // multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; - - int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to - // 125% of optimal flow. - - storedFluid = 0; - for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { - String fluidName = aFluids.get(i) - .getFluid() - .getUnlocalizedName(aFluids.get(i)); - if (fluidName.equals("ic2.fluidSuperheatedSteam")) { - flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount - this.storedFluid += aFluids.get(i).amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - if (!achievement) { - try { - GT_Mod.achievements.issueAchievement( - this.getBaseMetaTileEntity() - .getWorld() - .getPlayerEntityByName( - this.getBaseMetaTileEntity() - .getOwnerName()), - "efficientsteam"); - } catch (Exception e) {} - achievement = true; - } - } else if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") - || fluidName.equals("fluid.mfr.steam.still.name")) { - depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); - } - } - if (totalFlow <= 0) return 0; - tEU = totalFlow; - addOutput(GT_ModHandler.getSteam(totalFlow)); - if (totalFlow != realOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); - // if(totalFlow>aOptFlow){efficiency = 1.0f;} - tEU *= efficiency; - tEU = Math.max(1L, tEU * aBaseEff / 10000L); - } else { - tEU = tEU * aBaseEff / 10000L; - } - - return tEU; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - // Whenever there's a mode switch, there will be two messages on the player chat - // The two messages specify which two modes the turbine is on after the change - // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GT_Utility.sendChatToPlayer( - aPlayer, - looseFit ? "Fitting is Loose (Higher Flow)" : "Fitting is Tight (Higher Efficiency)"); - } - - if (looseFit) { - super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); - } else if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return (looseFit && CORE.RANDOM.nextInt(4) == 0) ? 0 : 1; - } - - @Override - public boolean isLooseMode() { - return looseFit; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting", looseFit); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - looseFit = aNBT.getBoolean("turbineFitting"); - } - - @Override - public String getMachineType() { - return "Large Super-heated Steam Turbine"; - } - - @Override - protected String getTurbineType() { - return "Super-heated Steam"; - } - - @Override - protected String getCasingName() { - return "Reinforced HP Steam Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java deleted file mode 100644 index c882b84aab..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ /dev/null @@ -1,215 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import static gtPlusPlus.core.lib.CORE.RANDOM; - -import java.util.ArrayList; - -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.FluidStack; - -import gregtech.GT_Mod; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -@SuppressWarnings("deprecation") -public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurbineBase { - - private float water; - private boolean achievement = false; - private boolean looseFit = false; - - public GT_MTE_LargeTurbine_Steam(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MTE_LargeTurbine_Steam(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_LargeTurbine_Steam(mName); - } - - @Override - public int getCasingMeta() { - return 1; - } - - @Override - public int getCasingTextureIndex() { - return 16; - } - - @Override - protected boolean requiresOutputHatch() { - return true; - } - - @Override - public int getPollutionPerSecond(ItemStack aStack) { - return 0; - } - - private int useWater(float input) { - water = water + input; - int usage = (int) water; - water = water - usage; - return usage; - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - return 0; - } - - @Override - long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (looseFit) { - aOptFlow *= 4; - if (aBaseEff > 10000) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff = 7500; - } else if (aBaseEff > 7500) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff *= 0.75f; - } else { - aBaseEff *= 0.75f; - } - } - // prevent overflow like that in SC Steam - long tEU = 0; - int totalFlow = 0; // Byproducts are based on actual flow - int flow = 0; - - // Variable required outside of loop for - // multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; - - int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to - // use up to - // 125% of - // optimal flow. - - storedFluid = 0; - for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and - // track totals. - String fluidName = aFluids.get(i) - .getFluid() - .getUnlocalizedName(aFluids.get(i)); - if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") - || fluidName.equals("fluid.mfr.steam.still.name")) { - flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount - this.storedFluid += aFluids.get(i).amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - if (!achievement) { - GT_Mod.achievements.issueAchievement( - this.getBaseMetaTileEntity() - .getWorld() - .getPlayerEntityByName( - this.getBaseMetaTileEntity() - .getOwnerName()), - "muchsteam"); - achievement = true; - } - } else if (fluidName.equals("ic2.fluidSuperheatedSteam")) { - depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); - } - } - if (totalFlow <= 0) return 0; - tEU = totalFlow; - int waterToOutput = useWater(totalFlow / 160.0f); - addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); - if (totalFlow != realOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); - // if(totalFlow>aOptFlow){efficiency = 1.0f;} - tEU *= efficiency; - tEU = Math.max(1L, tEU * aBaseEff / 20000L); - } else { - tEU = tEU * aBaseEff / 20000L; - } - - return tEU; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - // Whenever there's a mode switch, there will be two messages on the player chat - // The two messages specify which two modes the turbine is on after the change - // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GT_Utility.sendChatToPlayer( - aPlayer, - looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); - } - - if (looseFit) { - super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); - } else if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return (looseFit && RANDOM.nextInt(4) == 0) ? 0 : 1; - } - - @Override - public boolean isLooseMode() { - return looseFit; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting", looseFit); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - looseFit = aNBT.getBoolean("turbineFitting"); - } - - @Override - public String getMachineType() { - return "Large Steam Turbine"; - } - - @Override - protected String getTurbineType() { - return "Steam"; - } - - @Override - protected String getCasingName() { - return "Reinforced Steam Turbine Casing"; - } - - @Override - protected ITexture getTextureFrontFace() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); - } - - @Override - protected ITexture getTextureFrontFaceActive() { - return new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java deleted file mode 100644 index c343d170f2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ /dev/null @@ -1,886 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -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.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_Utility.filterValidMTEs; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -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 net.minecraftforge.fluids.FluidStack; - -import org.jetbrains.annotations.NotNull; - -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; -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 gregtech.api.enums.Materials; -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.items.GT_MetaGenerated_Tool; -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_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -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_Utility; -import gregtech.api.util.shutdown.ShutDownReason; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; - -public abstract class GregtechMetaTileEntity_LargerTurbineBase - extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - - protected int baseEff = 0; - protected long optFlow = 0; - protected long euPerTurbine = 0; - protected double realOptFlow = 0; - protected int storedFluid = 0; - protected int counter = 0; - protected boolean mFastMode = false; - protected double mufflerReduction = 1; - protected float[] flowMultipliers = new float[] { 1, 1, 1 }; - - public ITexture frontFace; - public ITexture frontFaceActive; - - public ArrayList mTurbineRotorHatches = new ArrayList<>(); - - public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - frontFace = getTextureFrontFace(); - frontFaceActive = getTextureFrontFaceActive(); - } - - public GregtechMetaTileEntity_LargerTurbineBase(String aName) { - super(aName); - frontFace = getTextureFrontFace(); - frontFaceActive = getTextureFrontFaceActive(); - } - - protected abstract ITexture getTextureFrontFace(); - - protected abstract ITexture getTextureFrontFaceActive(); - - protected abstract String getTurbineType(); - - protected abstract String getCasingName(); - - protected abstract boolean requiresOutputHatch(); - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the XL " + getTurbineType() + " Turbine") - .addInfo("Runs as fast as 16 Large Turbines of the same type, takes the space of 12") - .addInfo("Right-click with screwdriver to enable Fast Mode, to run it even faster") - .addInfo("Optimal flow will increase or decrease accordingly on mode switch") - .addInfo("Fast Mode increases speed to 48x instead of 16x, with some penalties") - .addInfo("Maintenance problems and turbine damage happen 12x as often in Fast Mode"); - if (getTurbineType().contains("Steam")) { - tt.addInfo("XL Steam Turbines can use Loose Mode with either Slow or Fast Mode"); - } - if (getTurbineType().equals("Plasma")) { - tt.addInfo("Plasma fuel efficiency is lower for high tier turbines when using low-grade plasmas") - .addInfo("Efficiency = ((FuelValue / 200,000)^2) / (EU per Turbine)"); - } - tt.addPollutionAmount(getPollutionPerSecond(null)) - .addInfo("Pollution is 3x higher in Fast Mode") - .addSeparator() - .beginStructureBlock(7, 9, 7, false) - .addController("Top Middle") - .addCasingInfoMin(getCasingName(), 360, false) - .addCasingInfoMin("Rotor Shaft", 30, false) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) - .addInputBus("Any 4 dot hint (min 1)", 4) - .addInputHatch("Any 4 dot hint(min 1)", 4); - if (requiresOutputHatch()) { - tt.addOutputHatch("Any 4 dot hint(min 1)", 4); - } - tt.addDynamoHatch("Any 4 dot hint(min 1)", 4) - .addMaintenanceHatch("Any 4 dot hint(min 1)", 4); - if (requiresMufflers()) { - tt.addMufflerHatch("Any 7 dot hint (x4)", 7); - } - tt.toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { - - @Override - @SuppressWarnings("SpellCheckingInspection") - protected IStructureDefinition computeValue(Class type) { - return StructureDefinition.builder() - // c = turbine casing - // s = turbine shaft - // t = turbine housing - // h = dynamo/maint - // m = muffler - .addShape( - STRUCTURE_PIECE_MAIN, - (new String[][] { { "ccchccc", "ccccccc", "ccmmmcc", "ccm~mcc", "ccmmmcc", "ccccccc", "ccchccc" }, - { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, - { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, - { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, - { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, - { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, - { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, - { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, - { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, })) - .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('s', lazy(t -> ofBlock(t.getShaftBlock(), t.getTurbineShaftMeta()))) - .addElement( - 't', - lazy( - t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) - .adder(GregtechMetaTileEntity_LargerTurbineBase::addTurbineHatch) - .hatchClass(GT_MetaTileEntity_Hatch_Turbine.class) - .casingIndex(t.getCasingTextureIndex()) - .dot(1) - .build())) - .addElement( - 'h', - lazy( - t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class) - .atLeast(InputBus, InputHatch, OutputHatch, Dynamo.or(TTDynamo), Maintenance) - .casingIndex(t.getCasingTextureIndex()) - .dot(4) - .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) - .addElement( - 'm', - lazy( - t -> buildHatchAdder(GregtechMetaTileEntity_LargerTurbineBase.class).atLeast(Muffler) - .casingIndex(t.getCasingTextureIndex()) - .dot(7) - .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) - .build(); - } - }; - - @Override - public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION.get(getClass()); - } - - private boolean requiresMufflers() { - if (!PollutionUtils.isPollutionEnabled()) { - return false; - } - return getPollutionPerSecond(null) > 0; - } - - public final double getMufflerReduction() { - double totalReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { - totalReduction += ((double) tHatch.calculatePollutionReduction(100)) / 100; - } - return totalReduction / 4; - } - - @Override - public void clearHatches() { - super.clearHatches(); - mTurbineRotorHatches.clear(); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - // we do not check for casing count here. the bare minimal is 372 but we only require 360 - boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); - log("Structure Check: " + aStructure); - if (mTurbineRotorHatches.size() != 12 || mMaintenanceHatches.size() != 1 - || (mDynamoHatches.size() < 1 && mTecTechDynamoHatches.size() < 1) - || (requiresMufflers() && mMufflerHatches.size() != 4) - || mInputBusses.size() < 1 - || mInputHatches.size() < 1 - || (requiresOutputHatch() && mOutputHatches.size() < 1)) { - log( - "Bad Hatches - Turbine Housings: " + mTurbineRotorHatches.size() - + ", Maint: " - + mMaintenanceHatches.size() - + ", Dynamo: " - + mDynamoHatches.size() - + ", Muffler: " - + mMufflerHatches.size() - + ", Input Buses: " - + mInputBusses.size() - + ", Input Hatches: " - + mInputHatches.size() - + ", Output Hatches: " - + mOutputHatches.size()); - return false; - } - mufflerReduction = getMufflerReduction(); - return aStructure; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, realBudget, env, false, true); - } - - public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine aTurbineHatch) { - log("Found GT_MetaTileEntity_Hatch_Turbine"); - updateTexture(aTileEntity, aBaseCasingIndex); - IGregTechTileEntity g = this.getBaseMetaTileEntity(); - if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { - boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch); - Logger.INFO("Injected Controller into Turbine Assembly. Found: " + this.mTurbineRotorHatches.size()); - return aDidAdd; - } else { - Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); - } - } - log("Bad Turbine Housing"); - return false; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - - public Block getCasingBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - public final Block getShaftBlock() { - return ModBlocks.blockSpecialMultiCasings; - } - - public abstract int getCasingMeta(); - - public byte getTurbineShaftMeta() { - return 0; - } - - public abstract int getCasingTextureIndex(); - - public abstract int getFuelValue(FluidStack aLiquid); - - public static boolean isValidTurbine(ItemStack aTurbine) { - return (aTurbine != null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool - && aTurbine.getItemDamage() >= 170 - && aTurbine.getItemDamage() <= 176); - } - - protected ArrayList getAllBufferedTurbines() { - startRecipeProcessing(); - ArrayList aTurbinesInStorage = new ArrayList<>(); - for (ItemStack aStack : getStoredInputs()) { - if (isValidTurbine(aStack)) { - int stackSize = aStack.stackSize; - while (stackSize > 0) { - int tmpStackSize = Math.min(stackSize, aStack.getMaxStackSize()); - ItemStack copy = aStack.copy(); - copy.stackSize = tmpStackSize; - aTurbinesInStorage.add(copy); - stackSize -= tmpStackSize; - } - } - } - endRecipeProcessing(); - return aTurbinesInStorage; - } - - public boolean areAllTurbinesTheSame() { - ArrayList aTurbineAssemblies = getFullTurbineAssemblies(); - if (aTurbineAssemblies.size() < 12) { - log("Found " + aTurbineAssemblies.size() + ", expected 12."); - return false; - } - AutoMap aTurbineMats = new AutoMap<>(); - AutoMap aTurbineSizes = new AutoMap<>(); - for (GT_MetaTileEntity_Hatch_Turbine aHatch : aTurbineAssemblies) { - aTurbineMats.add(GT_MetaGenerated_Tool.getPrimaryMaterial(aHatch.getTurbine())); - aTurbineSizes.add(getTurbineSize(aHatch.getTurbine())); - } - Materials aBaseMat = aTurbineMats.get(0); - int aBaseSize = aTurbineSizes.get(0); - for (int aSize : aTurbineSizes) { - if (aBaseSize != aSize) { - return false; - } - } - for (Materials aMat : aTurbineMats) { - if (aBaseMat != aMat) { - return false; - } - } - return true; - } - - public static int getTurbineSize(ItemStack aTurbine) { - if (isValidTurbine(aTurbine)) { - if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) { - return 1; - } else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) { - return 2; - } else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) { - return 3; - } else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) { - return 4; - } - } - return 0; - } - - public static String getTurbineSizeString(int aSize) { - return switch (aSize) { - case 1 -> "Small Turbine"; - case 2 -> "Turbine"; - case 3 -> "Large Turbine"; - case 4 -> "Huge Turbine"; - default -> ""; - }; - } - - protected ArrayList getEmptyTurbineAssemblies() { - ArrayList aEmptyTurbineRotorHatches = new ArrayList<>(); - // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties."); - for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { - if (!aTurbineHatch.hasTurbine()) { - aEmptyTurbineRotorHatches.add(aTurbineHatch); - } - } - return aEmptyTurbineRotorHatches; - } - - protected ArrayList getFullTurbineAssemblies() { - ArrayList aTurbineRotorHatches = new ArrayList<>(); - // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines."); - for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) { - if (aTurbineHatch.hasTurbine()) { - // log("Found Assembly with Turbine."); - aTurbineRotorHatches.add(aTurbineHatch); - } - } - return aTurbineRotorHatches; - } - - protected void depleteTurbineFromStock(ItemStack aTurbine) { - if (aTurbine == null) { - return; - } - startRecipeProcessing(); - for (GT_MetaTileEntity_Hatch_InputBus aInputBus : this.mInputBusses) { - for (int slot = aInputBus.getSizeInventory() - 1; slot >= 0; slot--) { - ItemStack aStack = aInputBus.getStackInSlot(slot); - if (aStack != null && GT_Utility.areStacksEqual(aStack, aTurbine)) { - aStack.stackSize -= aTurbine.stackSize; - updateSlots(); - endRecipeProcessing(); - return; - } - } - } - endRecipeProcessing(); - } - - @Override - public @NotNull CheckRecipeResult checkProcessing() { - try { - ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { - hatch: for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - ArrayList aTurbines = getAllBufferedTurbines(); - for (ItemStack aTurbineItem : aTurbines) { - if (aTurbineItem == null) { - continue; - } - if (aHatch.insertTurbine(aTurbineItem.copy())) { - depleteTurbineFromStock(aTurbineItem); - continue hatch; - } - } - } - } - - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - stopMachine(ShutDownReasonRegistry.NO_TURBINE); - return CheckRecipeResultRegistry.NO_TURBINE_FOUND; - } - - ArrayList tFluids = getStoredFluids(); - - if (tFluids.size() > 0) { - if (baseEff == 0 || optFlow == 0 - || counter >= 512 - || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity() - .hasInventoryBeenModified()) { - counter = 0; - float aTotalBaseEff = 0; - float aTotalOptimalFlow = 0; - - ItemStack aStack = getFullTurbineAssemblies().get(0) - .getTurbine(); - aTotalBaseEff += GT_Utility.safeInt( - (long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - aTotalOptimalFlow += GT_Utility.safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack) - .getSpeedMultiplier() * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50) - * getSpeedMultiplier()); - if (aTotalOptimalFlow < 0) { - aTotalOptimalFlow = 100; - } - - flowMultipliers[0] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mSteamMultiplier; - flowMultipliers[1] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mGasMultiplier; - flowMultipliers[2] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mPlasmaMultiplier; - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); - if (optFlow <= 0 || baseEff <= 0) { - stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - } else { - counter++; - } - } - - // How much the turbine should be producing with this flow - long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); - long difference = newPower - this.lEUt; // difference between current output and new output - - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the - // difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(10, GT_Utility.safeInt(Math.abs(difference) / 100)); - - if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed - // change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.lEUt += change; // Apply the change - } else { - this.lEUt = newPower; - } - if (this.lEUt <= 0) { - this.lEUt = 0; - this.mEfficiency = 0; - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } else { - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 10; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - // Play sounds (GT++ addition - GT multiblocks play no sounds) - enableAllTurbineHatches(); - return CheckRecipeResultRegistry.GENERATING; - } - } catch (Throwable t) { - t.printStackTrace(); - } - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - - @Override - public boolean doRandomMaintenanceDamage() { - if (getMaxParallelRecipes() == 0) { - stopMachine(ShutDownReasonRegistry.NO_TURBINE); - return false; - } - - if (mRuntime++ > 1000) { - mRuntime = 0; - - if (getBaseMetaTileEntity().getRandomNumber(6000) < getMaintenanceThreshold()) { - causeMaintenanceIssue(); - } - for (GT_MetaTileEntity_Hatch_Turbine aHatch : getFullTurbineAssemblies()) { - // This cycle depletes durability from the turbine rotors. - // The amount of times it is run depends on turbineDamageMultiplier - // In XL turbines, durability loss is around 5.2-5.3x faster than in singles - // To compensate for that, the mEU/t scaling is divided by 5 to make it only slightly faster - for (int i = 0; i < getTurbineDamageMultiplier(); i++) { - aHatch.damageTurbine(lEUt / 5, damageFactorLow, damageFactorHigh); - } - } - } - return true; - } - - @Override - public int getMaxParallelRecipes() { - return (getFullTurbineAssemblies().size()); - } - - abstract long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return this.getMaxParallelRecipes() == 12 ? 10000 : 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - public boolean isLooseMode() { - return false; - } - - @Override - public String[] getExtraInfoData() { - int mPollutionReduction = (int) (100 * mufflerReduction); - - String tRunning = mMaxProgresstime > 0 - ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.running.true") - + EnumChatFormatting.RESET - : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.running.false") - + EnumChatFormatting.RESET; - - String tMaintenance = getIdealStatus() == getRepairStatus() - ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") - + EnumChatFormatting.RESET - : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") - + EnumChatFormatting.RESET; - int tDura; - - StringBuilder aTurbineDamage = new StringBuilder(); - for (GT_MetaTileEntity_Hatch_Turbine aHatch : this.getFullTurbineAssemblies()) { - ItemStack aTurbine = aHatch.getTurbine(); - tDura = MathUtils.safeInt( - (long) (100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(aTurbine) - * (GT_MetaGenerated_Tool.getToolDamage(aTurbine)) + 1)); - aTurbineDamage.append(EnumChatFormatting.RED) - .append(GT_Utility.formatNumbers(tDura)) - .append(EnumChatFormatting.RESET) - .append("% | "); - } - - long storedEnergy = 0; - long maxEnergy = 0; - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : filterValidMTEs(mDynamoHatches)) { - storedEnergy += tHatch.getBaseMetaTileEntity() - .getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity() - .getEUCapacity(); - } - - boolean aIsSteam = this.getClass() - .getName() - .toLowerCase() - .contains("steam"); - - String[] ret = new String[] { - // 8 Lines available for information panels - tRunning + ": " - + EnumChatFormatting.RED - + GT_Utility.formatNumbers(((lEUt * mEfficiency) / 10000)) - + EnumChatFormatting.RESET - + " EU/t", - tMaintenance, - StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers((mEfficiency / 100F)) - + EnumChatFormatting.RESET - + "%", - 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.turbine.flow") + ": " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(MathUtils.safeInt((long) realOptFlow)) - + EnumChatFormatting.RESET - + " L/s" - + EnumChatFormatting.YELLOW - + " (" - + (isLooseMode() ? StatCollector.translateToLocal("GT5U.turbine.loose") - : StatCollector.translateToLocal("GT5U.turbine.tight")) - + ")", - StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " - + EnumChatFormatting.GOLD - + GT_Utility.formatNumbers(storedFluid) - + EnumChatFormatting.RESET - + "L", - StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + aTurbineDamage, - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(mPollutionReduction) - + EnumChatFormatting.RESET - + " %" }; - if (!aIsSteam) ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(MathUtils.safeInt((long) realOptFlow)) - + EnumChatFormatting.RESET - + " L/t"; - return ret; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean polluteEnvironment(int aPollutionLevel) { - if (this.requiresMufflers()) { - mPollution += aPollutionLevel * getPollutionMultiplier() * mufflerReduction; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { - if (mPollution >= 10000) { - if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10000)) { - mPollution -= 10000; - } - } else { - break; - } - } - return mPollution < 10000; - } - return true; - } - - @Override - public long maxAmperesOut() { - // This should not be a hard limit, due to TecTech dynamos - if (mFastMode) { - return 64; - } else { - return 16; - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mFastMode", mFastMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFastMode = aNBT.getBoolean("mFastMode"); - super.loadNBTData(aNBT); - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mFastMode = !mFastMode; - if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - public final ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, - ForgeDirection facing, int aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], - facing == side ? getFrontFacingTurbineTexture(aActive) - : Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()) }; - } - - protected ITexture getFrontFacingTurbineTexture(boolean isActive) { - if (isActive) { - return frontFaceActive; - } - return frontFace; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled()) { - enableAllTurbineHatches(); - } - if (this.maxProgresstime() <= 0) { - stopMachine(ShutDownReasonRegistry.NONE); - } - } - } - - @Override - public void stopMachine(@NotNull ShutDownReason reason) { - baseEff = 0; - optFlow = 0; - disableAllTurbineHatches(); - super.stopMachine(reason); - } - - @Override - public void onRemoval() { - super.onRemoval(); - for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { - h.clearController(); - } - disableAllTurbineHatches(); - this.mTurbineRotorHatches.clear(); - } - - public void enableAllTurbineHatches() { - updateTurbineHatches(this.isMachineRunning()); - } - - public void disableAllTurbineHatches() { - updateTurbineHatches(false); - } - - private Long mLastHatchUpdate; - - public void updateTurbineHatches(boolean aState) { - if (mLastHatchUpdate == null) { - mLastHatchUpdate = System.currentTimeMillis() / 1000; - } - if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis() / 1000) - mLastHatchUpdate) <= 2) { - return; - } - for (GT_MetaTileEntity_Hatch_Turbine h : filterValidMTEs(this.mTurbineRotorHatches)) { - h.setActive(aState); - } - - mLastHatchUpdate = System.currentTimeMillis() / 1000; - } - - @Override - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d == ForgeDirection.UP; - } - - /** - * Called every tick the Machine runs - */ - @Override - public boolean onRunningTick(ItemStack aStack) { - if (lEUt > 0) { - addEnergyOutput((lEUt * mEfficiency) / 10000); - return true; - } - return false; - } - - @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) { - return true; - } - if (this.mAllDynamoHatches.size() > 0) { - return addEnergyOutputMultipleDynamos(aEU, true); - } - return false; - } - - @Override - public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { - int injected = 0; - long aFirstVoltageFound = -1; - for (GT_MetaTileEntity_Hatch aDynamo : filterValidMTEs(mAllDynamoHatches)) { - long aVoltage = aDynamo.maxEUOutput(); - // Check against voltage to check when hatch mixing - if (aFirstVoltageFound == -1) { - aFirstVoltageFound = aVoltage; - } - } - - long leftToInject; - long aVoltage; - int aAmpsToInject; - int aRemainder; - int ampsOnCurrentHatch; - for (GT_MetaTileEntity_Hatch aDynamo : filterValidMTEs(mAllDynamoHatches)) { - leftToInject = aEU - injected; - aVoltage = aDynamo.maxEUOutput(); - aAmpsToInject = (int) (leftToInject / aVoltage); - aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); - - // add full amps - aDynamo.getBaseMetaTileEntity() - .increaseStoredEnergyUnits(aVoltage * ampsOnCurrentHatch, false); - injected += aVoltage * ampsOnCurrentHatch; - - // add reminder - if (aRemainder > 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { - aDynamo.getBaseMetaTileEntity() - .increaseStoredEnergyUnits(aRemainder, false); - injected += aRemainder; - } - } - return injected > 0; - } - - public int getSpeedMultiplier() { - return mFastMode ? 48 : 16; - } - - public int getMaintenanceThreshold() { - return mFastMode ? 12 : 1; - } - - public int getPollutionMultiplier() { - return mFastMode ? 3 : 1; - } - - public int getTurbineDamageMultiplier() { - return mFastMode ? 3 : 1; - } - - @Override - public boolean supportsBatchMode() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java new file mode 100644 index 0000000000..e57a7d7e77 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java @@ -0,0 +1,208 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import static gtPlusPlus.core.lib.GTPPCore.RANDOM; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +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.objects.GTRenderedTexture; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.recipe.maps.FuelBackend; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("deprecation") +public class MTELargeTurbineGas extends MTELargerTurbineBase { + + private static final HashSet BLACKLIST = new HashSet<>(); + + static { + BLACKLIST.add( + Materials.Benzene.getFluid(0) + .getFluid()); + } + + public MTELargeTurbineGas(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeTurbineGas(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeTurbineGas(mName); + } + + @Override + public int getCasingMeta() { + return 3; + } + + @Override + public int getCasingTextureIndex() { + return 58; + } + + @Override + protected boolean requiresOutputHatch() { + return false; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 4000; + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null) { + return 0; + } + GTRecipe tFuel = getRecipeMap().getBackend() + .findFuel(aLiquid); + if (tFuel != null) { + return tFuel.mSpecialValue; + } + return 0; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.gasTurbineFuels; + } + + @Override + public int getRecipeCatalystPriority() { + return -20; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + List fluids = getStoredFluids(); + for (FluidStack fluid : fluids) { + if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { + return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); + } + } + return super.checkProcessing(); + } + + @Override + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + if (aFluids.size() >= 1) { + int tEU = 0; + int actualOptimalFlow = 0; + FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. + // Doesn't matter which one. Ignore the rest! + int fuelValue = getFuelValue(firstFuelType); + // log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu"); + if (aOptFlow < fuelValue) { + // turbine too weak and/or fuel too powerful + // at least consume 1L + this.realOptFlow = 1; + // wastes the extra fuel and generate aOptFlow directly + depleteInput(new FluidStack(firstFuelType, 1)); + this.storedFluid += 1; + return GTUtility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); + } + + actualOptimalFlow = GTUtility.safeInt((long) (aOptFlow * (double) flowMultipliers[1] / fuelValue)); + this.realOptFlow = actualOptimalFlow; + + int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of + // optimal flow. Variable + // required outside of loop for + // multi-hatch scenarios. + int flow = 0; + int totalFlow = 0; + + storedFluid = 0; + for (FluidStack aFluid : aFluids) { + if (aFluid.isFluidEqual(firstFuelType)) { + flow = Math.min(aFluid.amount, remainingFlow); // try to use up to 125% of optimal flow w/o + // exceeding remainingFlow + depleteInput(new FluidStack(aFluid, flow)); // deplete that amount + this.storedFluid += aFluid.amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + if (totalFlow <= 0) return 0; + tEU = GTUtility.safeInt((long) totalFlow * fuelValue); + + if (totalFlow == actualOptimalFlow) { + tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + } else { + float efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); + tEU *= efficiency; + tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + } + + return tEU; + } + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (RANDOM.nextInt(4) == 0) ? 0 : 1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public String getMachineType() { + return "Large Gas Turbine"; + } + + @Override + protected String getTurbineType() { + return "Gas"; + } + + @Override + protected String getCasingName() { + return "Reinforced Gas Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java new file mode 100644 index 0000000000..310463e0d5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java @@ -0,0 +1,315 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import java.util.ArrayList; +import java.util.HashSet; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.MetaGeneratedTool; +import gregtech.api.objects.GTRenderedTexture; +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.recipe.maps.FuelBackend; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("deprecation") +public class MTELargeTurbinePlasma extends MTELargerTurbineBase { + + private static final HashSet BLACKLIST = new HashSet<>(); + + public MTELargeTurbinePlasma(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeTurbinePlasma(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeTurbinePlasma(mName); + } + + @Override + public int getCasingMeta() { + return 4; + } + + @Override + public int getCasingTextureIndex() { + return 60; + } + + @Override + protected boolean requiresOutputHatch() { + return true; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 0; + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null) { + return 0; + } + GTRecipe tFuel = getRecipeMap().getBackend() + .findFuel(aLiquid); + if (tFuel != null) { + return tFuel.mSpecialValue; + } + return 0; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.plasmaFuels; + } + + @Override + public int getRecipeCatalystPriority() { + return -20; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + + try { + ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); + if (aEmptyTurbineRotorHatches.size() > 0) { + hatch: for (MTEHatchTurbine aHatch : aEmptyTurbineRotorHatches) { + ArrayList aTurbines = getAllBufferedTurbines(); + for (ItemStack aTurbineItem : aTurbines) { + if (aTurbineItem == null) { + continue; + } + if (aHatch.insertTurbine(aTurbineItem.copy())) { + depleteTurbineFromStock(aTurbineItem); + continue hatch; + } + } + } + } + + if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + stopMachine(ShutDownReasonRegistry.NO_TURBINE); + return CheckRecipeResultRegistry.NO_TURBINE_FOUND; + } + + ArrayList tFluids = getStoredFluids(); + + if (tFluids.size() > 0) { + for (FluidStack fluid : tFluids) { + if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { + return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); + } + } + if (baseEff == 0 || optFlow == 0 + || counter >= 512 + || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity() + .hasInventoryBeenModified()) { + counter = 0; + + float aTotalBaseEff = 0; + float aTotalOptimalFlow = 0; + + ItemStack aStack = getFullTurbineAssemblies().get(0) + .getTurbine(); + aTotalBaseEff += GTUtility.safeInt( + (long) ((5F + ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + aTotalOptimalFlow += GTUtility + .safeInt( + (long) Math.max( + Float.MIN_NORMAL, + ((MetaGeneratedTool) aStack.getItem()).getToolStats(aStack) + .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(aStack).mToolSpeed + * 50)); + + // Calculate total EU/t (as shown on turbine tooltip (Fast mode doesn't affect)) + double aEUPerTurbine = aTotalOptimalFlow * 40 + * 0.0105 + * MetaGeneratedTool.getPrimaryMaterial(aStack).mPlasmaMultiplier + * (50.0f + (10.0f * ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack))); + aTotalOptimalFlow *= getSpeedMultiplier(); + + if (aTotalOptimalFlow < 0) { + aTotalOptimalFlow = 100; + } + + flowMultipliers[0] = MetaGeneratedTool.getPrimaryMaterial(aStack).mSteamMultiplier; + flowMultipliers[1] = MetaGeneratedTool.getPrimaryMaterial(aStack).mGasMultiplier; + flowMultipliers[2] = MetaGeneratedTool.getPrimaryMaterial(aStack).mPlasmaMultiplier; + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); + euPerTurbine = MathUtils.roundToClosestInt(aEUPerTurbine); + if (optFlow <= 0 || baseEff <= 0) { + stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + } else { + counter++; + } + } + + // How much the turbine should be producing with this flow + long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + + // Reduce produced power depending on the ratio between fuel value and turbine EU/t with the following + // formula: + // EU/t = EU/t * MIN(1, ( ( (FuelValue / 200) ^ 2 ) / EUPerTurbine)) + int fuelValue = 0; + if (tFluids.size() > 0) { + fuelValue = getFuelValue(new FluidStack(tFluids.get(0), 0)); + } + float magicValue = (fuelValue * 0.005f) * (fuelValue * 0.005f); + float efficiencyLoss = Math.min(1.0f, magicValue / euPerTurbine); + newPower *= efficiencyLoss; + + long difference = newPower - this.lEUt; // difference between current output and new output + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the + // difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, GTUtility.safeInt((long) Math.abs(difference) / 100)); + + if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed + // change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.lEUt += change; // Apply the change + } else { + this.lEUt = newPower; + } + if (this.lEUt <= 0) { + this.lEUt = 0; + this.mEfficiency = 0; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } else { + this.mMaxProgresstime = 20; + this.mEfficiencyIncrease = 10; + // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. + // Play sounds (GT++ addition - GT multiblocks play no sounds) + enableAllTurbineHatches(); + return CheckRecipeResultRegistry.GENERATING; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + + @Override + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + if (aFluids.size() >= 1) { + aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks + int tEU = 0; + + int actualOptimalFlow = 0; + + FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. + // Doesn't matter which one. Ignore the rest! + int fuelValue = getFuelValue(firstFuelType); + actualOptimalFlow = GTUtility + .safeInt((long) Math.ceil((double) aOptFlow * (double) flowMultipliers[2] / (double) fuelValue)); + this.realOptFlow = actualOptimalFlow; // For scanner info + + int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of + // optimal flow. Variable + // required outside of loop for + // multi-hatch scenarios. + int flow = 0; + int totalFlow = 0; + + storedFluid = 0; + for (FluidStack aFluid : aFluids) { + if (aFluid.isFluidEqual(firstFuelType)) { + flow = Math.min(aFluid.amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluid, flow)); // deplete that amount + this.storedFluid += aFluid.amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + String fn = FluidRegistry.getFluidName(firstFuelType); + String[] nameSegments = fn.split("\\.", 2); + if (nameSegments.length == 2) { + String outputName = nameSegments[1]; + FluidStack output = FluidRegistry.getFluidStack(outputName, totalFlow); + if (output == null) { + output = FluidRegistry.getFluidStack("molten." + outputName, totalFlow); + } + if (output != null) { + addOutput(output); + } + } + if (totalFlow <= 0) return 0; + tEU = GTUtility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow)); + + if (totalFlow == actualOptimalFlow) { + tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU)); + } else { + double efficiency = 1.0D - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); + + tEU = (int) (tEU * efficiency); + tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU)); + } + + return tEU; + } + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + @Override + public String getMachineType() { + return "Large Plasma Turbine"; + } + + @Override + protected String getTurbineType() { + return "Plasma"; + } + + @Override + protected String getCasingName() { + return "Reinforced Plasma Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java new file mode 100644 index 0000000000..0ef3ef0256 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java @@ -0,0 +1,126 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTELargeTurbineSCSteam extends MTELargerTurbineBase { + + public MTELargeTurbineSCSteam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeTurbineSCSteam(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeTurbineSCSteam(mName); + } + + @Override + public int getCasingMeta() { + return 15; + } + + @Override + public int getCasingTextureIndex() { + return 1538; + } + + @Override + protected boolean requiresOutputHatch() { + return true; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 0; + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + return 0; + } + + @Override + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + int tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + // Variable required outside of loop for + // multi-hatch scenarios. + this.realOptFlow = aOptFlow; + // this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + // Will there be an multiplier for SC? + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to + // 125% of optimal flow. + + storedFluid = 0; + FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1); + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { + if (GTUtility.areFluidsEqual(aFluids.get(i), tSCSteam, true)) { + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + if (totalFlow <= 0) return 0; + tEU = totalFlow; + addOutput(GTModHandler.getSteam(totalFlow * 100)); + if (totalFlow != realOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); + // if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); + } else { + tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); + } + + return tEU * 100L; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 8; + } + + @Override + public String getMachineType() { + return "Large Supercritical Steam Turbine"; + } + + @Override + protected String getTurbineType() { + return "Supercritical Steam"; + } + + @Override + protected String getCasingName() { + return "Reinforced SC Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return TextureFactory.of(TexturesGtBlock.Overlay_Machine_Controller_Advanced); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return TextureFactory.of(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java new file mode 100644 index 0000000000..7fdc36450d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import java.util.ArrayList; + +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.FluidStack; + +import gregtech.GTMod; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("deprecation") +public class MTELargeTurbineSHSteam extends MTELargerTurbineBase { + + public boolean achievement = false; + private boolean looseFit = false; + + public MTELargeTurbineSHSteam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeTurbineSHSteam(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeTurbineSHSteam(mName); + } + + @Override + public int getCasingMeta() { + return 2; + } + + @Override + public int getCasingTextureIndex() { + return 59; + } + + @Override + protected boolean requiresOutputHatch() { + return true; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 0; + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + return 0; + } + + @Override + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + if (looseFit) { + aOptFlow *= 4; + if (aBaseEff > 10000) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff = 7500; + } else if (aBaseEff > 7500) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff *= 0.75f; + } else { + aBaseEff *= 0.75f; + } + } + // prevent overflow like that in SC Steam + long tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + + // Variable required outside of loop for + // multi-hatch scenarios. + this.realOptFlow = aOptFlow * flowMultipliers[0]; + + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to + // 125% of optimal flow. + + storedFluid = 0; + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { + String fluidName = aFluids.get(i) + .getFluid() + .getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("ic2.fluidSuperheatedSteam")) { + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + try { + GTMod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity() + .getOwnerName()), + "efficientsteam"); + } catch (Exception e) {} + achievement = true; + } + } else if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") + || fluidName.equals("fluid.mfr.steam.still.name")) { + depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } + } + if (totalFlow <= 0) return 0; + tEU = totalFlow; + addOutput(GTModHandler.getSteam(totalFlow)); + if (totalFlow != realOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); + // if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1L, tEU * aBaseEff / 10000L); + } else { + tEU = tEU * aBaseEff / 10000L; + } + + return tEU; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode + // Whenever there's a mode switch, there will be two messages on the player chat + // The two messages specify which two modes the turbine is on after the change + // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) + if (side == getBaseMetaTileEntity().getFrontFacing()) { + looseFit ^= true; + GTUtility.sendChatToPlayer( + aPlayer, + looseFit ? "Fitting is Loose (Higher Flow)" : "Fitting is Tight (Higher Efficiency)"); + } + + if (looseFit) { + super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); + } else if (mFastMode) { + PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); + } + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (looseFit && GTPPCore.RANDOM.nextInt(4) == 0) ? 0 : 1; + } + + @Override + public boolean isLooseMode() { + return looseFit; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("turbineFitting", looseFit); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + looseFit = aNBT.getBoolean("turbineFitting"); + } + + @Override + public String getMachineType() { + return "Large Super-heated Steam Turbine"; + } + + @Override + protected String getTurbineType() { + return "Super-heated Steam"; + } + + @Override + protected String getCasingName() { + return "Reinforced HP Steam Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java new file mode 100644 index 0000000000..68cfc8cd1e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java @@ -0,0 +1,215 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import static gtPlusPlus.core.lib.GTPPCore.RANDOM; + +import java.util.ArrayList; + +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.FluidStack; + +import gregtech.GTMod; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +@SuppressWarnings("deprecation") +public class MTELargeTurbineSteam extends MTELargerTurbineBase { + + private float water; + private boolean achievement = false; + private boolean looseFit = false; + + public MTELargeTurbineSteam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTELargeTurbineSteam(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELargeTurbineSteam(mName); + } + + @Override + public int getCasingMeta() { + return 1; + } + + @Override + public int getCasingTextureIndex() { + return 16; + } + + @Override + protected boolean requiresOutputHatch() { + return true; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return 0; + } + + private int useWater(float input) { + water = water + input; + int usage = (int) water; + water = water - usage; + return usage; + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + return 0; + } + + @Override + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + if (looseFit) { + aOptFlow *= 4; + if (aBaseEff > 10000) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff = 7500; + } else if (aBaseEff > 7500) { + aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); + aBaseEff *= 0.75f; + } else { + aBaseEff *= 0.75f; + } + } + // prevent overflow like that in SC Steam + long tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + + // Variable required outside of loop for + // multi-hatch scenarios. + this.realOptFlow = aOptFlow * flowMultipliers[0]; + + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to + // use up to + // 125% of + // optimal flow. + + storedFluid = 0; + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and + // track totals. + String fluidName = aFluids.get(i) + .getFluid() + .getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") + || fluidName.equals("fluid.mfr.steam.still.name")) { + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + GTMod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity() + .getOwnerName()), + "muchsteam"); + achievement = true; + } + } else if (fluidName.equals("ic2.fluidSuperheatedSteam")) { + depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } + } + if (totalFlow <= 0) return 0; + tEU = totalFlow; + int waterToOutput = useWater(totalFlow / 160.0f); + addOutput(GTModHandler.getDistilledWater(waterToOutput)); + if (totalFlow != realOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); + // if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1L, tEU * aBaseEff / 20000L); + } else { + tEU = tEU * aBaseEff / 20000L; + } + + return tEU; + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode + // Whenever there's a mode switch, there will be two messages on the player chat + // The two messages specify which two modes the turbine is on after the change + // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) + if (side == getBaseMetaTileEntity().getFrontFacing()) { + looseFit ^= true; + GTUtility.sendChatToPlayer( + aPlayer, + looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); + } + + if (looseFit) { + super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); + } else if (mFastMode) { + PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); + } + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (looseFit && RANDOM.nextInt(4) == 0) ? 0 : 1; + } + + @Override + public boolean isLooseMode() { + return looseFit; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("turbineFitting", looseFit); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + looseFit = aNBT.getBoolean("turbineFitting"); + } + + @Override + public String getMachineType() { + return "Large Steam Turbine"; + } + + @Override + protected String getTurbineType() { + return "Steam"; + } + + @Override + protected String getCasingName() { + return "Reinforced Steam Turbine Casing"; + } + + @Override + protected ITexture getTextureFrontFace() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); + } + + @Override + protected ITexture getTextureFrontFaceActive() { + return new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java new file mode 100644 index 0000000000..69e3580f11 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java @@ -0,0 +1,884 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTDynamo; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +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 net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +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 gregtech.api.enums.Materials; +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.items.MetaGeneratedTool; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; + +public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase + implements ISurvivalConstructable { + + protected int baseEff = 0; + protected long optFlow = 0; + protected long euPerTurbine = 0; + protected double realOptFlow = 0; + protected int storedFluid = 0; + protected int counter = 0; + protected boolean mFastMode = false; + protected double mufflerReduction = 1; + protected float[] flowMultipliers = new float[] { 1, 1, 1 }; + + public ITexture frontFace; + public ITexture frontFaceActive; + + public ArrayList mTurbineRotorHatches = new ArrayList<>(); + + public MTELargerTurbineBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + frontFace = getTextureFrontFace(); + frontFaceActive = getTextureFrontFaceActive(); + } + + public MTELargerTurbineBase(String aName) { + super(aName); + frontFace = getTextureFrontFace(); + frontFaceActive = getTextureFrontFaceActive(); + } + + protected abstract ITexture getTextureFrontFace(); + + protected abstract ITexture getTextureFrontFaceActive(); + + protected abstract String getTurbineType(); + + protected abstract String getCasingName(); + + protected abstract boolean requiresOutputHatch(); + + @Override + protected final MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the XL " + getTurbineType() + " Turbine") + .addInfo("Runs as fast as 16 Large Turbines of the same type, takes the space of 12") + .addInfo("Right-click with screwdriver to enable Fast Mode, to run it even faster") + .addInfo("Optimal flow will increase or decrease accordingly on mode switch") + .addInfo("Fast Mode increases speed to 48x instead of 16x, with some penalties") + .addInfo("Maintenance problems and turbine damage happen 12x as often in Fast Mode"); + if (getTurbineType().contains("Steam")) { + tt.addInfo("XL Steam Turbines can use Loose Mode with either Slow or Fast Mode"); + } + if (getTurbineType().equals("Plasma")) { + tt.addInfo("Plasma fuel efficiency is lower for high tier turbines when using low-grade plasmas") + .addInfo("Efficiency = ((FuelValue / 200,000)^2) / (EU per Turbine)"); + } + tt.addPollutionAmount(getPollutionPerSecond(null)) + .addInfo("Pollution is 3x higher in Fast Mode") + .addSeparator() + .beginStructureBlock(7, 9, 7, false) + .addController("Top Middle") + .addCasingInfoMin(getCasingName(), 360, false) + .addCasingInfoMin("Rotor Shaft", 30, false) + .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1) + .addInputBus("Any 4 dot hint (min 1)", 4) + .addInputHatch("Any 4 dot hint(min 1)", 4); + if (requiresOutputHatch()) { + tt.addOutputHatch("Any 4 dot hint(min 1)", 4); + } + tt.addDynamoHatch("Any 4 dot hint(min 1)", 4) + .addMaintenanceHatch("Any 4 dot hint(min 1)", 4); + if (requiresMufflers()) { + tt.addMufflerHatch("Any 7 dot hint (x4)", 7); + } + tt.toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); + return tt; + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { + + @Override + @SuppressWarnings("SpellCheckingInspection") + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + // c = turbine casing + // s = turbine shaft + // t = turbine housing + // h = dynamo/maint + // m = muffler + .addShape( + STRUCTURE_PIECE_MAIN, + (new String[][] { { "ccchccc", "ccccccc", "ccmmmcc", "ccm~mcc", "ccmmmcc", "ccccccc", "ccchccc" }, + { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, + { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, + { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, + { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, + { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, + { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, + { "ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc" }, + { "ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc" }, })) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('s', lazy(t -> ofBlock(t.getShaftBlock(), t.getTurbineShaftMeta()))) + .addElement( + 't', + lazy( + t -> buildHatchAdder(MTELargerTurbineBase.class).adder(MTELargerTurbineBase::addTurbineHatch) + .hatchClass(MTEHatchTurbine.class) + .casingIndex(t.getCasingTextureIndex()) + .dot(1) + .build())) + .addElement( + 'h', + lazy( + t -> buildHatchAdder(MTELargerTurbineBase.class) + .atLeast(InputBus, InputHatch, OutputHatch, Dynamo.or(TTDynamo), Maintenance) + .casingIndex(t.getCasingTextureIndex()) + .dot(4) + .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) + .addElement( + 'm', + lazy( + t -> buildHatchAdder(MTELargerTurbineBase.class).atLeast(Muffler) + .casingIndex(t.getCasingTextureIndex()) + .dot(7) + .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) + .build(); + } + }; + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION.get(getClass()); + } + + private boolean requiresMufflers() { + if (!PollutionUtils.isPollutionEnabled()) { + return false; + } + return getPollutionPerSecond(null) > 0; + } + + public final double getMufflerReduction() { + double totalReduction = 0; + for (MTEHatchMuffler tHatch : filterValidMTEs(mMufflerHatches)) { + totalReduction += ((double) tHatch.calculatePollutionReduction(100)) / 100; + } + return totalReduction / 4; + } + + @Override + public void clearHatches() { + super.clearHatches(); + mTurbineRotorHatches.clear(); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // we do not check for casing count here. the bare minimal is 372 but we only require 360 + boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0); + log("Structure Check: " + aStructure); + if (mTurbineRotorHatches.size() != 12 || mMaintenanceHatches.size() != 1 + || (mDynamoHatches.size() < 1 && mTecTechDynamoHatches.size() < 1) + || (requiresMufflers() && mMufflerHatches.size() != 4) + || mInputBusses.size() < 1 + || mInputHatches.size() < 1 + || (requiresOutputHatch() && mOutputHatches.size() < 1)) { + log( + "Bad Hatches - Turbine Housings: " + mTurbineRotorHatches.size() + + ", Maint: " + + mMaintenanceHatches.size() + + ", Dynamo: " + + mDynamoHatches.size() + + ", Muffler: " + + mMufflerHatches.size() + + ", Input Buses: " + + mInputBusses.size() + + ", Input Hatches: " + + mInputHatches.size() + + ", Output Hatches: " + + mOutputHatches.size()); + return false; + } + mufflerReduction = getMufflerReduction(); + return aStructure; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 2); + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 3, 0, realBudget, env, false, true); + } + + public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchTurbine aTurbineHatch) { + log("Found GT_MetaTileEntity_Hatch_Turbine"); + updateTexture(aTileEntity, aBaseCasingIndex); + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { + boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch); + Logger.INFO("Injected Controller into Turbine Assembly. Found: " + this.mTurbineRotorHatches.size()); + return aDidAdd; + } else { + Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); + } + } + log("Bad Turbine Housing"); + return false; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Block getCasingBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + public final Block getShaftBlock() { + return ModBlocks.blockSpecialMultiCasings; + } + + public abstract int getCasingMeta(); + + public byte getTurbineShaftMeta() { + return 0; + } + + public abstract int getCasingTextureIndex(); + + public abstract int getFuelValue(FluidStack aLiquid); + + public static boolean isValidTurbine(ItemStack aTurbine) { + return (aTurbine != null && aTurbine.getItem() instanceof MetaGeneratedTool + && aTurbine.getItemDamage() >= 170 + && aTurbine.getItemDamage() <= 176); + } + + protected ArrayList getAllBufferedTurbines() { + startRecipeProcessing(); + ArrayList aTurbinesInStorage = new ArrayList<>(); + for (ItemStack aStack : getStoredInputs()) { + if (isValidTurbine(aStack)) { + int stackSize = aStack.stackSize; + while (stackSize > 0) { + int tmpStackSize = Math.min(stackSize, aStack.getMaxStackSize()); + ItemStack copy = aStack.copy(); + copy.stackSize = tmpStackSize; + aTurbinesInStorage.add(copy); + stackSize -= tmpStackSize; + } + } + } + endRecipeProcessing(); + return aTurbinesInStorage; + } + + public boolean areAllTurbinesTheSame() { + ArrayList aTurbineAssemblies = getFullTurbineAssemblies(); + if (aTurbineAssemblies.size() < 12) { + log("Found " + aTurbineAssemblies.size() + ", expected 12."); + return false; + } + AutoMap aTurbineMats = new AutoMap<>(); + AutoMap aTurbineSizes = new AutoMap<>(); + for (MTEHatchTurbine aHatch : aTurbineAssemblies) { + aTurbineMats.add(MetaGeneratedTool.getPrimaryMaterial(aHatch.getTurbine())); + aTurbineSizes.add(getTurbineSize(aHatch.getTurbine())); + } + Materials aBaseMat = aTurbineMats.get(0); + int aBaseSize = aTurbineSizes.get(0); + for (int aSize : aTurbineSizes) { + if (aBaseSize != aSize) { + return false; + } + } + for (Materials aMat : aTurbineMats) { + if (aBaseMat != aMat) { + return false; + } + } + return true; + } + + public static int getTurbineSize(ItemStack aTurbine) { + if (isValidTurbine(aTurbine)) { + if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) { + return 1; + } else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) { + return 2; + } else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) { + return 3; + } else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) { + return 4; + } + } + return 0; + } + + public static String getTurbineSizeString(int aSize) { + return switch (aSize) { + case 1 -> "Small Turbine"; + case 2 -> "Turbine"; + case 3 -> "Large Turbine"; + case 4 -> "Huge Turbine"; + default -> ""; + }; + } + + protected ArrayList getEmptyTurbineAssemblies() { + ArrayList aEmptyTurbineRotorHatches = new ArrayList<>(); + // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties."); + for (MTEHatchTurbine aTurbineHatch : this.mTurbineRotorHatches) { + if (!aTurbineHatch.hasTurbine()) { + aEmptyTurbineRotorHatches.add(aTurbineHatch); + } + } + return aEmptyTurbineRotorHatches; + } + + protected ArrayList getFullTurbineAssemblies() { + ArrayList aTurbineRotorHatches = new ArrayList<>(); + // log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines."); + for (MTEHatchTurbine aTurbineHatch : this.mTurbineRotorHatches) { + if (aTurbineHatch.hasTurbine()) { + // log("Found Assembly with Turbine."); + aTurbineRotorHatches.add(aTurbineHatch); + } + } + return aTurbineRotorHatches; + } + + protected void depleteTurbineFromStock(ItemStack aTurbine) { + if (aTurbine == null) { + return; + } + startRecipeProcessing(); + for (MTEHatchInputBus aInputBus : this.mInputBusses) { + for (int slot = aInputBus.getSizeInventory() - 1; slot >= 0; slot--) { + ItemStack aStack = aInputBus.getStackInSlot(slot); + if (aStack != null && GTUtility.areStacksEqual(aStack, aTurbine)) { + aStack.stackSize -= aTurbine.stackSize; + updateSlots(); + endRecipeProcessing(); + return; + } + } + } + endRecipeProcessing(); + } + + @Override + public @NotNull CheckRecipeResult checkProcessing() { + try { + ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); + if (aEmptyTurbineRotorHatches.size() > 0) { + hatch: for (MTEHatchTurbine aHatch : aEmptyTurbineRotorHatches) { + ArrayList aTurbines = getAllBufferedTurbines(); + for (ItemStack aTurbineItem : aTurbines) { + if (aTurbineItem == null) { + continue; + } + if (aHatch.insertTurbine(aTurbineItem.copy())) { + depleteTurbineFromStock(aTurbineItem); + continue hatch; + } + } + } + } + + if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + stopMachine(ShutDownReasonRegistry.NO_TURBINE); + return CheckRecipeResultRegistry.NO_TURBINE_FOUND; + } + + ArrayList tFluids = getStoredFluids(); + + if (tFluids.size() > 0) { + if (baseEff == 0 || optFlow == 0 + || counter >= 512 + || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity() + .hasInventoryBeenModified()) { + counter = 0; + float aTotalBaseEff = 0; + float aTotalOptimalFlow = 0; + + ItemStack aStack = getFullTurbineAssemblies().get(0) + .getTurbine(); + aTotalBaseEff += GTUtility.safeInt( + (long) ((5F + ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + aTotalOptimalFlow += GTUtility.safeInt( + (long) Math.max( + Float.MIN_NORMAL, + ((MetaGeneratedTool) aStack.getItem()).getToolStats(aStack) + .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(aStack).mToolSpeed * 50) + * getSpeedMultiplier()); + if (aTotalOptimalFlow < 0) { + aTotalOptimalFlow = 100; + } + + flowMultipliers[0] = MetaGeneratedTool.getPrimaryMaterial(aStack).mSteamMultiplier; + flowMultipliers[1] = MetaGeneratedTool.getPrimaryMaterial(aStack).mGasMultiplier; + flowMultipliers[2] = MetaGeneratedTool.getPrimaryMaterial(aStack).mPlasmaMultiplier; + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); + if (optFlow <= 0 || baseEff <= 0) { + stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + } else { + counter++; + } + } + + // How much the turbine should be producing with this flow + long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + long difference = newPower - this.lEUt; // difference between current output and new output + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the + // difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, GTUtility.safeInt(Math.abs(difference) / 100)); + + if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed + // change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.lEUt += change; // Apply the change + } else { + this.lEUt = newPower; + } + if (this.lEUt <= 0) { + this.lEUt = 0; + this.mEfficiency = 0; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } else { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 10; + // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. + // Play sounds (GT++ addition - GT multiblocks play no sounds) + enableAllTurbineHatches(); + return CheckRecipeResultRegistry.GENERATING; + } + } catch (Throwable t) { + t.printStackTrace(); + } + return CheckRecipeResultRegistry.NO_FUEL_FOUND; + } + + @Override + public boolean doRandomMaintenanceDamage() { + if (getMaxParallelRecipes() == 0) { + stopMachine(ShutDownReasonRegistry.NO_TURBINE); + return false; + } + + if (mRuntime++ > 1000) { + mRuntime = 0; + + if (getBaseMetaTileEntity().getRandomNumber(6000) < getMaintenanceThreshold()) { + causeMaintenanceIssue(); + } + for (MTEHatchTurbine aHatch : getFullTurbineAssemblies()) { + // This cycle depletes durability from the turbine rotors. + // The amount of times it is run depends on turbineDamageMultiplier + // In XL turbines, durability loss is around 5.2-5.3x faster than in singles + // To compensate for that, the mEU/t scaling is divided by 5 to make it only slightly faster + for (int i = 0; i < getTurbineDamageMultiplier(); i++) { + aHatch.damageTurbine(lEUt / 5, damageFactorLow, damageFactorHigh); + } + } + } + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (getFullTurbineAssemblies().size()); + } + + abstract long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return this.getMaxParallelRecipes() == 12 ? 10000 : 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public boolean isLooseMode() { + return false; + } + + @Override + public String[] getExtraInfoData() { + int mPollutionReduction = (int) (100 * mufflerReduction); + + String tRunning = mMaxProgresstime > 0 + ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.running.true") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.running.false") + + EnumChatFormatting.RESET; + + String tMaintenance = getIdealStatus() == getRepairStatus() + ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") + + EnumChatFormatting.RESET; + int tDura; + + StringBuilder aTurbineDamage = new StringBuilder(); + for (MTEHatchTurbine aHatch : this.getFullTurbineAssemblies()) { + ItemStack aTurbine = aHatch.getTurbine(); + tDura = MathUtils.safeInt( + (long) (100.0f / MetaGeneratedTool.getToolMaxDamage(aTurbine) + * (MetaGeneratedTool.getToolDamage(aTurbine)) + 1)); + aTurbineDamage.append(EnumChatFormatting.RED) + .append(GTUtility.formatNumbers(tDura)) + .append(EnumChatFormatting.RESET) + .append("% | "); + } + + long storedEnergy = 0; + long maxEnergy = 0; + for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + boolean aIsSteam = this.getClass() + .getName() + .toLowerCase() + .contains("steam"); + + String[] ret = new String[] { + // 8 Lines available for information panels + tRunning + ": " + + EnumChatFormatting.RED + + GTUtility.formatNumbers(((lEUt * mEfficiency) / 10000)) + + EnumChatFormatting.RESET + + " EU/t", + tMaintenance, + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers((mEfficiency / 100F)) + + EnumChatFormatting.RESET + + "%", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(MathUtils.safeInt((long) realOptFlow)) + + EnumChatFormatting.RESET + + " L/s" + + EnumChatFormatting.YELLOW + + " (" + + (isLooseMode() ? StatCollector.translateToLocal("GT5U.turbine.loose") + : StatCollector.translateToLocal("GT5U.turbine.tight")) + + ")", + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + + EnumChatFormatting.GOLD + + GTUtility.formatNumbers(storedFluid) + + EnumChatFormatting.RESET + + "L", + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + aTurbineDamage, + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(mPollutionReduction) + + EnumChatFormatting.RESET + + " %" }; + if (!aIsSteam) ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(MathUtils.safeInt((long) realOptFlow)) + + EnumChatFormatting.RESET + + " L/t"; + return ret; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean polluteEnvironment(int aPollutionLevel) { + if (this.requiresMufflers()) { + mPollution += aPollutionLevel * getPollutionMultiplier() * mufflerReduction; + for (MTEHatchMuffler tHatch : filterValidMTEs(mMufflerHatches)) { + if (mPollution >= 10000) { + if (PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10000)) { + mPollution -= 10000; + } + } else { + break; + } + } + return mPollution < 10000; + } + return true; + } + + @Override + public long maxAmperesOut() { + // This should not be a hard limit, due to TecTech dynamos + if (mFastMode) { + return 64; + } else { + return 16; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mFastMode", mFastMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFastMode = aNBT.getBoolean("mFastMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mFastMode = !mFastMode; + if (mFastMode) { + PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); + } + } + + public final ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, + ForgeDirection facing, int aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], + facing == side ? getFrontFacingTurbineTexture(aActive) + : Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()) }; + } + + protected ITexture getFrontFacingTurbineTexture(boolean isActive) { + if (isActive) { + return frontFaceActive; + } + return frontFace; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity() + .hasWorkJustBeenEnabled()) { + enableAllTurbineHatches(); + } + if (this.maxProgresstime() <= 0) { + stopMachine(ShutDownReasonRegistry.NONE); + } + } + } + + @Override + public void stopMachine(@NotNull ShutDownReason reason) { + baseEff = 0; + optFlow = 0; + disableAllTurbineHatches(); + super.stopMachine(reason); + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (MTEHatchTurbine h : this.mTurbineRotorHatches) { + h.clearController(); + } + disableAllTurbineHatches(); + this.mTurbineRotorHatches.clear(); + } + + public void enableAllTurbineHatches() { + updateTurbineHatches(this.isMachineRunning()); + } + + public void disableAllTurbineHatches() { + updateTurbineHatches(false); + } + + private Long mLastHatchUpdate; + + public void updateTurbineHatches(boolean aState) { + if (mLastHatchUpdate == null) { + mLastHatchUpdate = System.currentTimeMillis() / 1000; + } + if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis() / 1000) - mLastHatchUpdate) <= 2) { + return; + } + for (MTEHatchTurbine h : filterValidMTEs(this.mTurbineRotorHatches)) { + h.setActive(aState); + } + + mLastHatchUpdate = System.currentTimeMillis() / 1000; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d == ForgeDirection.UP; + } + + /** + * Called every tick the Machine runs + */ + @Override + public boolean onRunningTick(ItemStack aStack) { + if (lEUt > 0) { + addEnergyOutput((lEUt * mEfficiency) / 10000); + return true; + } + return false; + } + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (this.mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + @Override + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long aFirstVoltageFound = -1; + for (MTEHatch aDynamo : filterValidMTEs(mAllDynamoHatches)) { + long aVoltage = aDynamo.maxEUOutput(); + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + aFirstVoltageFound = aVoltage; + } + } + + long leftToInject; + long aVoltage; + int aAmpsToInject; + int aRemainder; + int ampsOnCurrentHatch; + for (MTEHatch aDynamo : filterValidMTEs(mAllDynamoHatches)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); + + // add full amps + aDynamo.getBaseMetaTileEntity() + .increaseStoredEnergyUnits(aVoltage * ampsOnCurrentHatch, false); + injected += aVoltage * ampsOnCurrentHatch; + + // add reminder + if (aRemainder > 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { + aDynamo.getBaseMetaTileEntity() + .increaseStoredEnergyUnits(aRemainder, false); + injected += aRemainder; + } + } + return injected > 0; + } + + public int getSpeedMultiplier() { + return mFastMode ? 48 : 16; + } + + public int getMaintenanceThreshold() { + return mFastMode ? 12 : 1; + } + + public int getPollutionMultiplier() { + return mFastMode ? 3 : 1; + } + + public int getTurbineDamageMultiplier() { + return mFastMode ? 3 : 1; + } + + @Override + public boolean supportsBatchMode() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 13bef7c885..7476cd2b90 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -6,14 +6,14 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElement import static com.gtnewhorizon.structurelib.structure.StructureUtility.onlyIf; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.Energy; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -import static gregtech.api.util.GT_Utility.filterValidMTEs; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTEnergy; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTDynamo; +import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase.GTPPHatchElement.TTEnergy; import javax.annotation.Nullable; @@ -49,37 +49,37 @@ import com.gtnewhorizons.modularui.common.widget.SlotGroup; import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; -import gregtech.api.enums.GT_Values; +import gregtech.api.enums.GTValues; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; 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_Dynamo; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.objects.GTRenderedTexture; 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_Utility; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.MovingAverageLong; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.preloader.asm.AsmConfig; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; -public class GregtechMetaTileEntity_PowerSubStationController extends - GregtechMeta_MultiBlockBase implements ISurvivalConstructable { +public class GregtechMetaTileEntity_PowerSubStationController + extends GTPPMultiBlockBase implements ISurvivalConstructable { private static enum TopState { MayBeTop, @@ -118,8 +118,8 @@ public class GregtechMetaTileEntity_PowerSubStationController extends } @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); tt.addMachineType(getMachineType()) .addInfo("Consumes " + this.ENERGY_TAX + "% of the average voltage of all energy type hatches") .addInfo("Does not require maintenance") @@ -135,7 +135,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends .addEnergyHatch("Any Casing", 1) .addSubChannelUsage("capacitor", "Vanadium Capacitor Cell Tier") .addSubChannelUsage("height", "Height of structure") - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); + .toolTipFinisher(GTPPCore.GT_Tooltip_Builder.get()); return tt; } @@ -144,7 +144,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { if (side == facing) { return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), - new GT_RenderedTexture( + new GTRenderedTexture( aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER) }; } @@ -160,7 +160,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { // if (mBatteryCapacity <= 0) return false; - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -214,7 +214,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends public static int getMaxHatchTier(int aCellTier) { switch (aCellTier) { case 9 -> { - return GT_Values.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; + return GTValues.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; } default -> { if (aCellTier < 4) { @@ -434,13 +434,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends } int tier = getMaxHatchTier(level); long volSum = 0; - for (GT_MetaTileEntity_Hatch hatch : mAllDynamoHatches) { + for (MTEHatch hatch : mAllDynamoHatches) { if (hatch.mTier > tier || hatch.mTier < 3) { return false; } volSum += (8L << (hatch.mTier * 2)); } - for (GT_MetaTileEntity_Hatch hatch : mAllEnergyHatches) { + for (MTEHatch hatch : mAllEnergyHatches) { if (hatch.mTier > tier || hatch.mTier < 3) { return false; } @@ -458,11 +458,11 @@ public class GregtechMetaTileEntity_PowerSubStationController extends return false; } else { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + if (aMetaTileEntity instanceof MTEHatchEnergy) { return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + } else if (aMetaTileEntity instanceof MTEHatchDynamo) { return addToMachineList(aTileEntity, aBaseCasingIndex); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + } else if (aMetaTileEntity instanceof MTEHatchMaintenance) { return addToMachineList(aTileEntity, aBaseCasingIndex); } else { if (isThisHatchMultiDynamo(aMetaTileEntity)) { @@ -624,18 +624,18 @@ public class GregtechMetaTileEntity_PowerSubStationController extends long aInputAverage = 0; long aOutputAverage = 0; // Input Power - for (GT_MetaTileEntity_Hatch THatch : filterValidMTEs(this.mDischargeHatches)) { + for (MTEHatch THatch : filterValidMTEs(this.mDischargeHatches)) { aInputAverage += drawEnergyFromHatch(THatch); } - for (GT_MetaTileEntity_Hatch tHatch : filterValidMTEs(this.mAllEnergyHatches)) { + for (MTEHatch tHatch : filterValidMTEs(this.mAllEnergyHatches)) { aInputAverage += drawEnergyFromHatch(tHatch); } // Output Power - for (GT_MetaTileEntity_Hatch THatch : filterValidMTEs(this.mChargeHatches)) { + for (MTEHatch THatch : filterValidMTEs(this.mChargeHatches)) { aOutputAverage += addEnergyToHatch(THatch); } - for (GT_MetaTileEntity_Hatch tHatch : filterValidMTEs(this.mAllDynamoHatches)) { + for (MTEHatch tHatch : filterValidMTEs(this.mAllDynamoHatches)) { aOutputAverage += addEnergyToHatch(tHatch); } // reset progress time @@ -680,10 +680,10 @@ public class GregtechMetaTileEntity_PowerSubStationController extends String storedEnergyText; if (this.getEUVar() > this.mBatteryCapacity) { - storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + storedEnergyText = EnumChatFormatting.RED + GTUtility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; } else { - storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + storedEnergyText = EnumChatFormatting.GREEN + GTUtility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; } @@ -693,10 +693,10 @@ public class GregtechMetaTileEntity_PowerSubStationController extends return new String[] { "Ergon Energy - District Sub-Station", "Stored EU: " + storedEnergyText, "Capacity: " + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(this.maxEUStore()) + + GTUtility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, "Running Costs: " + EnumChatFormatting.RED - + GT_Utility.formatNumbers(this.computeEnergyTax()) + + GTUtility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", "Controller Mode: " + mode, @@ -710,23 +710,23 @@ public class GregtechMetaTileEntity_PowerSubStationController extends + "]", "----------------------", "Stats for Nerds", "Average Input: " + EnumChatFormatting.BLUE - + GT_Utility.formatNumbers(this.getAverageEuAdded()) + + GTUtility.formatNumbers(this.getAverageEuAdded()) + EnumChatFormatting.RESET + " EU", "Average Output: " + EnumChatFormatting.GOLD - + GT_Utility.formatNumbers(this.getAverageEuConsumed()) + + GTUtility.formatNumbers(this.getAverageEuConsumed()) + EnumChatFormatting.RESET + " EU", "Total Input: " + EnumChatFormatting.BLUE - + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + + GTUtility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", "Total Output: " + EnumChatFormatting.GOLD - + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + + GTUtility.formatNumbers(this.mTotalEnergyConsumed) + EnumChatFormatting.RESET + " EU", "Total Costs: " + EnumChatFormatting.RED - + GT_Utility.formatNumbers(this.mTotalEnergyLost) + + GTUtility.formatNumbers(this.mTotalEnergyLost) + EnumChatFormatting.RESET + " EU", }; } @@ -844,7 +844,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) .setPos(4, 4) .setSize(149, 149)) .widget(new SlotWidget(inventoryHandler, 0).setPos(154, 4)) @@ -896,13 +896,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends .setDefaultColor(COLOR_TEXT_WHITE.get()) .setPos(10, 40)) .widget( - new DrawableWidget().setDrawable(GTPP_UITextures.PICTURE_ENERGY_FRAME) + new DrawableWidget().setDrawable(GTPPUITextures.PICTURE_ENERGY_FRAME) .setPos(4, 155) .setSize(149, 7)) .widget(new FakeSyncWidget.FloatSyncer(this::getProgress, val -> clientProgress = val)) .widget( new ProgressBar().setProgress(this::getProgress) - .setTexture(GTPP_UITextures.PROGRESSBAR_PSS_ENERGY, 147) + .setTexture(GTPPUITextures.PROGRESSBAR_PSS_ENERGY, 147) .setDirection(ProgressBar.Direction.RIGHT) .setPos(5, 156) .setSize(147, 5)) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/MTESolarHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/MTESolarHeater.java new file mode 100644 index 0000000000..64925c9bb1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/MTESolarHeater.java @@ -0,0 +1,343 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.misc; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +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.MTETieredMachineBlock; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.MTESolarTower; + +public class MTESolarHeater extends MTETieredMachineBlock { + + public boolean mHasTower = false; + private MTESolarTower mTower = null; + + private int mTX, mTY, mTZ; + private Byte mRequiredFacing; + + public MTESolarHeater(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public MTESolarHeater(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll(this.mDescriptionArray, "Point me at a Solar Tower", GTPPCore.GT_Tooltip.get()); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GTRenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTESolarHeater(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, 0); + } + + @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 String[] getInfoData() { + return new String[] { this.getLocalName(), "Testificate" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return facing.offsetY == 0; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + /* + * aNBT.setBoolean("mHasTower", mHasTower); if (this.mHasTower) { aNBT.setInteger("mTX", mTX); + * aNBT.setInteger("mTY", mTY); aNBT.setInteger("mTZ", mTZ); } + */ + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + /* + * this.mHasTower = aNBT.getBoolean("mHasTower"); if (this.mHasTower) { if (aNBT.hasKey("mTX")) this.mTX = + * aNBT.getInteger("mTX"); if (aNBT.hasKey("mTY")) this.mTY = aNBT.getInteger("mTY"); if (aNBT.hasKey("mTZ")) + * this.mTZ = aNBT.getInteger("mTZ"); } + */ + } + + @Override + public long getInputTier() { + return 0; + } + + @Override + public long getOutputTier() { + return 0; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aStack) { + return false; + } + + @Override + public void onExplosion() {} + + public boolean hasSolarTower() { + return mHasTower; + } + + public MTESolarTower getSolarTower() { + if (this.mHasTower) { + return mTower; + } + return null; + } + + public boolean canSeeSky() { + if (this.getBaseMetaTileEntity() + .getWorld() + .canBlockSeeTheSky( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getYCoord() + 1, + this.getBaseMetaTileEntity() + .getZCoord())) { + return true; + } + return false; + } + + public boolean setSolarTower(MTESolarTower aTowerTile) { + if (!hasSolarTower()) { + this.mTX = aTowerTile.getBaseMetaTileEntity() + .getXCoord(); + this.mTY = (int) aTowerTile.getBaseMetaTileEntity() + .getYCoord(); + this.mTZ = aTowerTile.getBaseMetaTileEntity() + .getZCoord(); + this.mHasTower = true; + this.mTower = aTowerTile; + return true; + } + return false; + } + + public boolean clearSolarTower() { + if (mHasTower || mRequiredFacing != null || this.mTower != null) { + this.mTX = 0; + this.mTY = 0; + this.mTZ = 0; + this.mRequiredFacing = null; + this.mTower = null; + this.mHasTower = false; + return true; + } + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onRemoval() { + super.onRemoval(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side.offsetY == 0; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public void onFacingChange() { + super.onFacingChange(); + } + + @Override + public void doExplosion(long aExplosionPower) {} +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java deleted file mode 100644 index 141f4bbc43..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java +++ /dev/null @@ -1,343 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.misc; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -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_TieredMachineBlock; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_SolarTower; - -public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock { - - public boolean mHasTower = false; - private GregtechMetaTileEntity_SolarTower mTower = null; - - private int mTX, mTY, mTZ; - private Byte mRequiredFacing; - - public TileEntitySolarHeater(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public TileEntitySolarHeater(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll(this.mDescriptionArray, "Point me at a Solar Tower", CORE.GT_Tooltip.get()); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new TileEntitySolarHeater(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, 0); - } - - @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 String[] getInfoData() { - return new String[] { this.getLocalName(), "Testificate" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return facing.offsetY == 0; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - /* - * aNBT.setBoolean("mHasTower", mHasTower); if (this.mHasTower) { aNBT.setInteger("mTX", mTX); - * aNBT.setInteger("mTY", mTY); aNBT.setInteger("mTZ", mTZ); } - */ - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - /* - * this.mHasTower = aNBT.getBoolean("mHasTower"); if (this.mHasTower) { if (aNBT.hasKey("mTX")) this.mTX = - * aNBT.getInteger("mTX"); if (aNBT.hasKey("mTY")) this.mTY = aNBT.getInteger("mTY"); if (aNBT.hasKey("mTZ")) - * this.mTZ = aNBT.getInteger("mTZ"); } - */ - } - - @Override - public long getInputTier() { - return 0; - } - - @Override - public long getOutputTier() { - return 0; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return false; - } - - @Override - public void onExplosion() {} - - public boolean hasSolarTower() { - return mHasTower; - } - - public GregtechMetaTileEntity_SolarTower getSolarTower() { - if (this.mHasTower) { - return mTower; - } - return null; - } - - public boolean canSeeSky() { - if (this.getBaseMetaTileEntity() - .getWorld() - .canBlockSeeTheSky( - this.getBaseMetaTileEntity() - .getXCoord(), - this.getBaseMetaTileEntity() - .getYCoord() + 1, - this.getBaseMetaTileEntity() - .getZCoord())) { - return true; - } - return false; - } - - public boolean setSolarTower(GregtechMetaTileEntity_SolarTower aTowerTile) { - if (!hasSolarTower()) { - this.mTX = aTowerTile.getBaseMetaTileEntity() - .getXCoord(); - this.mTY = (int) aTowerTile.getBaseMetaTileEntity() - .getYCoord(); - this.mTZ = aTowerTile.getBaseMetaTileEntity() - .getZCoord(); - this.mHasTower = true; - this.mTower = aTowerTile; - return true; - } - return false; - } - - public boolean clearSolarTower() { - if (mHasTower || mRequiredFacing != null || this.mTower != null) { - this.mTX = 0; - this.mTY = 0; - this.mTZ = 0; - this.mRequiredFacing = null; - this.mTower = null; - this.mHasTower = false; - return true; - } - return false; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onRemoval() { - super.onRemoval(); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side.offsetY == 0; - } - - @Override - public boolean isInputFacing(ForgeDirection side) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public void onFacingChange() { - super.onFacingChange(); - } - - @Override - public void doExplosion(long aExplosionPower) {} -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java deleted file mode 100644 index ee6ccff4b1..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java +++ /dev/null @@ -1,111 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.objects.GT_ItemStack; -import gtPlusPlus.core.lib.CORE; - -public abstract class GT_MetaTileEntity_RedstoneBase extends GT_MetaTileEntity_TieredMachineBlock { - - protected int mOpenerCount; - - public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, - String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, - String[] aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_RedstoneBase(String aName, int aTier, int aInvSlotCount, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public final boolean isSimpleMachine() { - return false; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return side != getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public final boolean isValidSlot(int aIndex) { - return false; - } - - @Override - public final boolean isFacingValid(ForgeDirection facing) { - return true; - } - - @Override - public final boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public abstract void saveNBTData(NBTTagCompound aNBT); - - @Override - public abstract void loadNBTData(NBTTagCompound aNBT); - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - return false; - } - - @Override - public final void onOpenGUI() { - super.onOpenGUI(); - mOpenerCount++; - } - - @Override - public final void onCloseGUI() { - super.onCloseGUI(); - mOpenerCount--; - } - - public boolean hasRedstoneSignal() { - if (getBaseMetaTileEntity().getStrongestRedstone() > 0) { - return true; - } - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (getBaseMetaTileEntity().getOutputRedstoneSignal(side) > 0) { - return true; - } - } - 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 String[] getDescription() { - return ArrayUtils.add(this.mDescriptionArray, CORE.GT_Tooltip.get()); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java deleted file mode 100644 index 174a13d3c8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java +++ /dev/null @@ -1,205 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GT_MetaTileEntity_RedstoneButtonPanel extends GT_MetaTileEntity_RedstoneBase { - - public byte mRedstoneStrength = 0, mType = 0, mUpdate = 0; - - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[64]; - - static { - for (int i = 0; i < 64; i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/ButtonPanel/" + i); - } - } - - public GT_MetaTileEntity_RedstoneButtonPanel(int aID) { - super( - aID, - "redstone.button.panel", - "Button Panel", - 5, - 0, - "Right-click with Screwdriver to change Button Design"); - } - - public GT_MetaTileEntity_RedstoneButtonPanel(final String aName, String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneButtonPanel(this.mName, mDescriptionArray, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mRedstoneStrength", mRedstoneStrength); - aNBT.setByte("mType", mType); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); - mType = aNBT.getByte("mType"); - } - - @Override - public void onValueUpdate(byte aValue) { - mRedstoneStrength = (byte) (aValue & 15); - mType = (byte) (aValue >>> 4); - } - - @Override - public byte getUpdateData() { - return (byte) ((mRedstoneStrength & 15) | (mType << 4)); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) { - if (getBaseMetaTileEntity().isServerSide()) { - mUpdate = 2; - switch (mType) { - case 0: - default: - switch (side) { - case DOWN, UP -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (aZ * 4)); - case NORTH -> mRedstoneStrength = (byte) ((byte) (4 - aX * 4) + 4 * (byte) (4 - aY * 4)); - case SOUTH -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (4 - aY * 4)); - case WEST -> mRedstoneStrength = (byte) ((byte) (aZ * 4) + 4 * (byte) (4 - aY * 4)); - case EAST -> mRedstoneStrength = (byte) ((byte) (4 - aZ * 4) + 4 * (byte) (4 - aY * 4)); - } - break; - case 1: - switch (side) { - case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength - ^ (1 << (((byte) (aX * 2) + 2 * (byte) (aZ * 2))))); - case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength - ^ (1 << (((byte) (2 - aX * 2) + 2 * (byte) (2 - aY * 2))))); - case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength - ^ (1 << (((byte) (aX * 2) + 2 * (byte) (2 - aY * 2))))); - case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength - ^ (1 << (((byte) (aZ * 2) + 2 * (byte) (2 - aY * 2))))); - case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength - ^ (1 << (((byte) (2 - aZ * 2) + 2 * (byte) (2 - aY * 2))))); - } - break; - case 2: - switch (side) { - case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (aZ * 4)))); - case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); - case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); - case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); - case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); - } - break; - } - } - return true; - } - return false; - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (getBaseMetaTileEntity().isServerSide()) { - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - if (mUpdate > 0) { - mUpdate--; - } else if (getBaseMetaTileEntity().isAllowedToWork()) { - mRedstoneStrength = 0; - } - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - getBaseMetaTileEntity().setStrongOutputRedstoneSignal( - side, - side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal( - side, - side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); - } - } - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 3); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getSides(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getSidesActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], - new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1] }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_Off) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_On) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_Off) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_On) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_Off) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_On) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java deleted file mode 100644 index 3b9b9af9a0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java +++ /dev/null @@ -1,654 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; - -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.CycleButtonWidget; -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 gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.IRedstoneCircuitBlock; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.modularui.IAddUIWidgets; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_CircuitryBehavior; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.ISerializableObject; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_RedstoneBase - implements IRedstoneCircuitBlock, IAddUIWidgets { - - public int mGate = 0, mGateData[] = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - public boolean bOutput = true; - - public GT_MetaTileEntity_RedstoneCircuitBlock(int aID) { - super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone"); - } - - public GT_MetaTileEntity_RedstoneCircuitBlock(final String aName, String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, 1, 5, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescriptionArray, this.mTextures); - } - - @Override - public boolean hasSidedRedstoneOutputBehavior() { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(ForgeDirection side) { - return !this.isOutputFacing(side); - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == this.getOutputFacing(); - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public long maxEUInput() { - return GT_Values.V[1]; - } - - @Override - public long maxEUOutput() { - return bOutput ? GT_Values.V[1] : 0; - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long maxAmperesOut() { - return 1; - } - - @Override - public int getSizeInventory() { - return 5; - } - - @Override - public long maxEUStore() { - return GT_Values.V[3] * 1024; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mGate", mGate); - aNBT.setIntArray("mGateData", mGateData); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mGate = aNBT.getInteger("mGate"); - mGateData = aNBT.getIntArray("mGateData"); - if (mGateData.length != 8) mGateData = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - } - - public void switchGateForward(boolean aShift) { - try { - Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); - ArrayList tList = new ArrayList<>(); - tList.addAll(tKeys); - if (tList.size() <= 0) return; - Collections.sort(tList); - if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); - int tIndex = Collections.binarySearch(tList, mGate); - tIndex += aShift ? 16 : 1; - while (tIndex >= tList.size()) tIndex -= tList.size(); - mGate = tList.get(tIndex); - switchGate(); - } catch (Throwable e) { - GT_Log.err.print(e); - } - } - - public void switchGateBackward(boolean aShift) { - try { - Set tKeys = GregTech_API.sCircuitryBehaviors.keySet(); - ArrayList tList = new ArrayList<>(); - tList.addAll(tKeys); - if (tList.size() <= 0) return; - Collections.sort(tList); - if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); - int tIndex = Collections.binarySearch(tList, mGate); - tIndex -= aShift ? 16 : 1; - while (tIndex < 0) tIndex += tList.size(); - mGate = tList.get(tIndex); - switchGate(); - } catch (Throwable e) { - GT_Log.err.print(e); - } - } - - @Override - public void onFacingChange() { - resetRedstone(); - } - - private void resetRedstone() { - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.DOWN, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.UP, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.NORTH, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.SOUTH, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.WEST, (byte) 0); - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.EAST, (byte) 0); - } - - public void changeGateData(int aIndex, int aValue) { - mGateData[aIndex] += aValue; - validateGateData(); - } - - public void stackGateData(int aIndex, ItemStack aStack) { - mGateData[aIndex] = GT_Utility.stackToInt(aStack); - validateGateData(); - } - - private void switchGate() { - resetRedstone(); - Arrays.fill(mGateData, 0); - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) try { - tBehaviour.initParameters(mGateData, this); - } catch (Throwable e) { - GT_Log.err.print(e); - } - validateGateData(); - } - - private void validateGateData() { - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) try { - tBehaviour.validateParameters(mGateData, this); - } catch (Throwable e) { - GT_Log.err.print(e); - } - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - validateGateData(); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - getBaseMetaTileEntity().setGenericRedstoneOutput(true); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null; - if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { - if (getBaseMetaTileEntity().isActive()) { - GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tBehaviour != null) { - try { - tBehaviour.onTick(mGateData, this); - if (tBehaviour.displayItemStack(mGateData, this, 0)) - mInventory[1] = getCoverByID(mGateData[0]); - if (tBehaviour.displayItemStack(mGateData, this, 1)) - mInventory[2] = getCoverByID(mGateData[1]); - if (tBehaviour.displayItemStack(mGateData, this, 2)) - mInventory[3] = getCoverByID(mGateData[2]); - if (tBehaviour.displayItemStack(mGateData, this, 3)) - mInventory[4] = getCoverByID(mGateData[3]); - } catch (Throwable e) { - GT_Log.err.print(e); - } - } - } - getBaseMetaTileEntity().setErrorDisplayID(0); - } else { - getBaseMetaTileEntity().setErrorDisplayID(1); - } - } - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - // Only Calc server-side - if (!this.getBaseMetaTileEntity() - .isServerSide()) { - return; - } - // Emit Redstone - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - byte aRedstone = getBaseMetaTileEntity().getOutputRedstoneSignal(side); - this.getBaseMetaTileEntity() - .setInternalOutputRedstoneSignal(side, aRedstone); - } - } - - @Override - public final boolean hasRedstoneSignal() { - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (getBaseMetaTileEntity().getOutputRedstoneSignal(side) > 0) { - return true; - } - } - return false; - } - - @Override - public boolean allowGeneralRedstoneOutput() { - return true; - } - - /** The Item List for Covers */ - public static final Map sCoversItems = new HashMap<>(); - - private static void initCovers() { - for (GT_ItemStack aKey : GregTech_API.sCovers.keySet()) { - ItemStack aStack = aKey.toStack() - .copy(); - if (aStack != null) { - sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); - } - } - } - - public static ItemStack getCoverByID(int aStack) { - if (sCoversItems.isEmpty()) { - initCovers(); - } - return sCoversItems.get(Integer.valueOf(aStack)); - } - - @Override - public ForgeDirection getOutputFacing() { - return getBaseMetaTileEntity().getBackFacing(); - } - - @Override - public boolean setRedstone(byte aStrength, ForgeDirection side) { - if (getOutputRedstone(side) != aStrength) { - if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(1, false)) { - getBaseMetaTileEntity().setInternalOutputRedstoneSignal(side, aStrength); - getBaseMetaTileEntity().setErrorDisplayID(0); - return true; - } else { - getBaseMetaTileEntity().setErrorDisplayID(1); - return false; - } - } - return false; - } - - /* - * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == - * getOutputFacing()) { if (side == ForgeDirection.DOWN) return aRedstone ? 56 : 54; if (side == ForgeDirection.UP) - * return aRedstone ? 53 : 52; return aRedstone ? 94 : 93; } if (side == ForgeDirection.DOWN) return aRedstone ? 60 - * : 59; if (side == ForgeDirection.UP) return aRedstone ? 58 : 57; return aRedstone ? 62 : 61; } - */ - - @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; - } - - public byte getOutputRedstone(ForgeDirection side) { - return getBaseMetaTileEntity().getOutputRedstoneSignal(side); - } - - @Override - public byte getInputRedstone(ForgeDirection side) { - return getBaseMetaTileEntity().getInternalInputRedstoneSignal(side); - } - - @Override - public Block getBlockAtSide(ForgeDirection side) { - return getBaseMetaTileEntity().getBlockAtSide(side); - } - - @Override - public byte getMetaIDAtSide(ForgeDirection side) { - return getBaseMetaTileEntity().getMetaIDAtSide(side); - } - - @Override - public TileEntity getTileEntityAtSide(ForgeDirection side) { - return getBaseMetaTileEntity().getTileEntityAtSide(side); - } - - @Override - public int getRandom(int aRange) { - return getBaseMetaTileEntity().getRandomNumber(aRange); - } - - @Override - public GT_CoverBehavior getCover(ForgeDirection side) { - return (GT_CoverBehavior) getBaseMetaTileEntity().getCoverBehaviorAtSideNew(side); - } - - @Override - public int getCoverID(ForgeDirection side) { - return getBaseMetaTileEntity().getCoverIDAtSide(side); - } - - @Override - public int getCoverVariable(ForgeDirection side) { - return ((ISerializableObject.LegacyCoverData) getBaseMetaTileEntity().getComplexCoverDataAtSide(side)).get(); - } - - @Override - public ICoverable getOwnTileEntity() { - return getBaseMetaTileEntity(); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getSides(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getSidesActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - private GT_RenderedTexture getBase() { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off), - new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On), - new GT_RenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On) }; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new DrawableWidget().setDrawable(GTPP_UITextures.PICTURE_REDSTONE_CIRCUIT_SCREEN) - .setPos(43, 5) - .setSize(108, 72)); - for (int i = 0; i < 4; i++) { - final int index = i; - builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { - ItemStack tStack = widget.getContext() - .getPlayer().inventory.getItemStack(); - if (tStack == null) { - changeGateData( - index, - clickData.mouseButton == 0 ? clickData.shift ? +128 : +1 : clickData.shift ? -128 : -1); - } else { - tStack = GT_Utility.copy(tStack); - if (clickData.mouseButton != 0) tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); - stackGateData(index, tStack); - } - }) - .setBackground(GT_UITextures.BUTTON_STANDARD, GTPP_UITextures.OVERLAY_BUTTON_PLUS_MINUS) - .setPos(7, 5 + i * 18) - .setSize(18, 18)) - .widget( - SlotWidget.phantom(inventoryHandler, i + 1) - .disableInteraction() - .setPos(25, 5 + i * 18)); - } - builder.widget( - new CycleButtonWidget().setToggle(() -> bOutput, val -> bOutput = val) - .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) - .setStaticTexture(GT_UITextures.OVERLAY_BUTTON_EMIT_ENERGY) - .addTooltip("Toggle EU Output") - .setPos(151, 5) - .setSize(18, 18)) - .widget( - new CycleButtonWidget() - .setToggle(() -> getBaseMetaTileEntity().isActive(), val -> getBaseMetaTileEntity().setActive(val)) - .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) - .setStaticTexture(GTPP_UITextures.OVERLAY_BUTTON_ACTIVE_STATE) - .addTooltip("Toggle Active State") - .setPos(151, 23) - .setSize(18, 18)) - .widget(new ButtonWidget().setOnClick((clickData, widget) -> { - if (clickData.mouseButton == 0) switchGateForward(clickData.shift); - else switchGateBackward(clickData.shift); - }) - .setBackground(GT_UITextures.BUTTON_STANDARD, GTPP_UITextures.OVERLAY_BUTTON_CHANGE_MODE) - .addTooltip("Change Redstone Circuit") - .setPos(151, 41) - .setSize(18, 18)); - - builder.widget(new FakeSyncWidget.IntegerSyncer(() -> mGate, val -> mGate = val)); - for (int i = 0; i < mGateData.length; i++) { - final int index = i; - builder.widget(new FakeSyncWidget.IntegerSyncer(() -> mGateData[index], val -> mGateData[index] = val)); - } - - builder.widget(new DrawableWidget().setDrawable(() -> { - if (getBaseMetaTileEntity().getErrorDisplayID() > 0) { - if ((getBaseMetaTileEntity().getTimer() / 5) % 2 == 0) { - return GTPP_UITextures.PICTURE_ELECTRICITY_ERROR; - } else { - return null; - } - } else { - return GTPP_UITextures.PICTURE_ELECTRICITY_FINE; - } - }) - .setPos(140, 9) - .setSize(7, 7)) - .widget( - new FakeSyncWidget.IntegerSyncer( - () -> getBaseMetaTileEntity().getErrorDisplayID(), - val -> getBaseMetaTileEntity().setErrorDisplayID(val))); - - builder.widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getName(); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 8)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getDescription(); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 19)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 0); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 33)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 1); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 44)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 2); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 55)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 3); - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(46, 66)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) { - String tString = tCircuit.getDataDisplay(mGateData, 0); - return tString == null ? GT_Utility.parseNumberToString(mGateData[0]) : tString; - } - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(99, 33)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) { - String tString = tCircuit.getDataDisplay(mGateData, 1); - return tString == null ? GT_Utility.parseNumberToString(mGateData[1]) : tString; - } - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(99, 44)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) { - String tString = tCircuit.getDataDisplay(mGateData, 2); - return tString == null ? GT_Utility.parseNumberToString(mGateData[2]) : tString; - } - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(99, 55)) - .widget(TextWidget.dynamicString(() -> { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(mGate); - if (tCircuit != null) { - String tString = tCircuit.getDataDisplay(mGateData, 3); - return tString == null ? GT_Utility.parseNumberToString(mGateData[3]) : tString; - } - return ""; - }) - .setSynced(false) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(99, 66)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java deleted file mode 100644 index 06dd76c3f4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java +++ /dev/null @@ -1,73 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GT_MetaTileEntity_RedstoneLamp extends GT_MetaTileEntity_RedstoneBase { - - public byte mRedstoneStrength = 0, mType = 0; - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[2]; - - static { - sIconList[0] = new CustomIcon("TileEntities/gt4/redstone/Lamp/off"); - sIconList[1] = new CustomIcon("TileEntities/gt4/redstone/Lamp/on"); - } - - public GT_MetaTileEntity_RedstoneLamp(int aID) { - super(aID, "redstone.lamp", "Redstone Controlled Lamp", 0, 0, "Redstone Controlled Lamp"); - } - - public GT_MetaTileEntity_RedstoneLamp(final String aName, String[] aDescription, final ITexture[][][] aTextures) { - super(aName, 0, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneLamp(this.mName, mDescriptionArray, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) {} - - @Override - public void loadNBTData(NBTTagCompound aNBT) {} - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - getBaseMetaTileEntity().setLightValue(getBaseMetaTileEntity().getStrongestRedstone()); - getBaseMetaTileEntity().setActive(getBaseMetaTileEntity().getStrongestRedstone() > 0); - } - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getSides(i); - rTextures[1][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 1 : 0)][aColorIndex + 1]; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(sIconList[0]) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(sIconList[1]) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java deleted file mode 100644 index b3b9d0fdcb..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java +++ /dev/null @@ -1,139 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GT_MetaTileEntity_RedstoneStrengthDisplay extends GT_MetaTileEntity_RedstoneBase { - - public byte mRedstoneStrength = 0, mType = 0; - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[144]; - - static { - for (int i = 0; i < 144; i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Display/" + i); - } - } - - public GT_MetaTileEntity_RedstoneStrengthDisplay(int aID, String aUnlocal, String aLocal, String aDescription) { - super(aID, aUnlocal, aLocal, 5, 0, aDescription); - } - - public GT_MetaTileEntity_RedstoneStrengthDisplay(final String aName, String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneStrengthDisplay(this.mName, mDescriptionArray, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mRedstoneStrength", mRedstoneStrength); - aNBT.setByte("mType", mType); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); - mType = aNBT.getByte("mType"); - } - - @Override - public void onValueUpdate(byte aValue) { - mRedstoneStrength = (byte) (aValue & 15); - mType = (byte) (aValue >>> 4); - } - - @Override - public byte getUpdateData() { - return (byte) ((mRedstoneStrength & 15) | (mType << 4)); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { - mRedstoneStrength = getBaseMetaTileEntity().getStrongestRedstone(); - } - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 6); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getSides(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFront(i); - rTextures[6][i + 1] = this.getSidesActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], - new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1] }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java deleted file mode 100644 index 5821dbab1a..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java +++ /dev/null @@ -1,54 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GT_MetaTileEntity_RedstoneStrengthScale extends GT_MetaTileEntity_RedstoneStrengthDisplay { - - public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[32]; - - static { - for (int i = 0; i < 32; i++) { - sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Scale/" + i); - } - } - - public GT_MetaTileEntity_RedstoneStrengthScale(int aID) { - super(aID, "redstone.display.scale", "Redstone Scale", "Redstone Strength on a Scale"); - } - - public GT_MetaTileEntity_RedstoneStrengthScale(final String aName, String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_RedstoneStrengthScale(this.mName, mDescriptionArray, this.mTextures); - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 2); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], - new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; - } - return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneBase.java new file mode 100644 index 0000000000..6da66be563 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneBase.java @@ -0,0 +1,111 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTItemStack; +import gtPlusPlus.core.lib.GTPPCore; + +public abstract class MTERedstoneBase extends MTETieredMachineBlock { + + protected int mOpenerCount; + + public MTERedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, + String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public MTERedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, + String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public MTERedstoneBase(String aName, int aTier, int aInvSlotCount, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public final boolean isSimpleMachine() { + return false; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aStack) { + return side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public final boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public final boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public abstract void saveNBTData(NBTTagCompound aNBT); + + @Override + public abstract void loadNBTData(NBTTagCompound aNBT); + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + return false; + } + + @Override + public final void onOpenGUI() { + super.onOpenGUI(); + mOpenerCount++; + } + + @Override + public final void onCloseGUI() { + super.onCloseGUI(); + mOpenerCount--; + } + + public boolean hasRedstoneSignal() { + if (getBaseMetaTileEntity().getStrongestRedstone() > 0) { + return true; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(side) > 0) { + return true; + } + } + 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 String[] getDescription() { + return ArrayUtils.add(this.mDescriptionArray, GTPPCore.GT_Tooltip.get()); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneButtonPanel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneButtonPanel.java new file mode 100644 index 0000000000..a83d05f928 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneButtonPanel.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTERedstoneButtonPanel extends MTERedstoneBase { + + public byte mRedstoneStrength = 0, mType = 0, mUpdate = 0; + + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[64]; + + static { + for (int i = 0; i < 64; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/ButtonPanel/" + i); + } + } + + public MTERedstoneButtonPanel(int aID) { + super( + aID, + "redstone.button.panel", + "Button Panel", + 5, + 0, + "Right-click with Screwdriver to change Button Design"); + } + + public MTERedstoneButtonPanel(final String aName, String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERedstoneButtonPanel(this.mName, mDescriptionArray, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mRedstoneStrength", mRedstoneStrength); + aNBT.setByte("mType", mType); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); + mType = aNBT.getByte("mType"); + } + + @Override + public void onValueUpdate(byte aValue) { + mRedstoneStrength = (byte) (aValue & 15); + mType = (byte) (aValue >>> 4); + } + + @Override + public byte getUpdateData() { + return (byte) ((mRedstoneStrength & 15) | (mType << 4)); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { + if (getBaseMetaTileEntity().isServerSide()) { + mUpdate = 2; + switch (mType) { + case 0: + default: + switch (side) { + case DOWN, UP -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (aZ * 4)); + case NORTH -> mRedstoneStrength = (byte) ((byte) (4 - aX * 4) + 4 * (byte) (4 - aY * 4)); + case SOUTH -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (4 - aY * 4)); + case WEST -> mRedstoneStrength = (byte) ((byte) (aZ * 4) + 4 * (byte) (4 - aY * 4)); + case EAST -> mRedstoneStrength = (byte) ((byte) (4 - aZ * 4) + 4 * (byte) (4 - aY * 4)); + } + break; + case 1: + switch (side) { + case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength + ^ (1 << (((byte) (aX * 2) + 2 * (byte) (aZ * 2))))); + case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength + ^ (1 << (((byte) (2 - aX * 2) + 2 * (byte) (2 - aY * 2))))); + case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength + ^ (1 << (((byte) (aX * 2) + 2 * (byte) (2 - aY * 2))))); + case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength + ^ (1 << (((byte) (aZ * 2) + 2 * (byte) (2 - aY * 2))))); + case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength + ^ (1 << (((byte) (2 - aZ * 2) + 2 * (byte) (2 - aY * 2))))); + } + break; + case 2: + switch (side) { + case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (aZ * 4)))); + case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4)))); + } + break; + } + } + return true; + } + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (getBaseMetaTileEntity().isServerSide()) { + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + if (mUpdate > 0) { + mUpdate--; + } else if (getBaseMetaTileEntity().isAllowedToWork()) { + mRedstoneStrength = 0; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + getBaseMetaTileEntity().setStrongOutputRedstoneSignal( + side, + side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal( + side, + side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength); + } + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 3); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GTRenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1] }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_Off) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_On) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_Off) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_On) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_Off) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_On) }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneCircuitBlock.java new file mode 100644 index 0000000000..20cd569e24 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneCircuitBlock.java @@ -0,0 +1,652 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; + +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.CycleButtonWidget; +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IRedstoneCircuitBlock; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.CircuitryBehavior; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTUtility; +import gregtech.api.util.ISerializableObject; +import gtPlusPlus.xmod.gregtech.api.gui.GTPPUITextures; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTERedstoneCircuitBlock extends MTERedstoneBase implements IRedstoneCircuitBlock, IAddUIWidgets { + + public int mGate = 0, mGateData[] = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + public boolean bOutput = true; + + public MTERedstoneCircuitBlock(int aID) { + super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone"); + } + + public MTERedstoneCircuitBlock(final String aName, String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 1, 5, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERedstoneCircuitBlock(this.mName, mDescriptionArray, this.mTextures); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return !this.isOutputFacing(side); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == this.getOutputFacing(); + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUInput() { + return GTValues.V[1]; + } + + @Override + public long maxEUOutput() { + return bOutput ? GTValues.V[1] : 0; + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public int getSizeInventory() { + return 5; + } + + @Override + public long maxEUStore() { + return GTValues.V[3] * 1024; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mGate", mGate); + aNBT.setIntArray("mGateData", mGateData); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mGate = aNBT.getInteger("mGate"); + mGateData = aNBT.getIntArray("mGateData"); + if (mGateData.length != 8) mGateData = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + } + + public void switchGateForward(boolean aShift) { + try { + Set tKeys = GregTechAPI.sCircuitryBehaviors.keySet(); + ArrayList tList = new ArrayList<>(); + tList.addAll(tKeys); + if (tList.size() <= 0) return; + Collections.sort(tList); + if (!GregTechAPI.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); + int tIndex = Collections.binarySearch(tList, mGate); + tIndex += aShift ? 16 : 1; + while (tIndex >= tList.size()) tIndex -= tList.size(); + mGate = tList.get(tIndex); + switchGate(); + } catch (Throwable e) { + GTLog.err.print(e); + } + } + + public void switchGateBackward(boolean aShift) { + try { + Set tKeys = GregTechAPI.sCircuitryBehaviors.keySet(); + ArrayList tList = new ArrayList<>(); + tList.addAll(tKeys); + if (tList.size() <= 0) return; + Collections.sort(tList); + if (!GregTechAPI.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0); + int tIndex = Collections.binarySearch(tList, mGate); + tIndex -= aShift ? 16 : 1; + while (tIndex < 0) tIndex += tList.size(); + mGate = tList.get(tIndex); + switchGate(); + } catch (Throwable e) { + GTLog.err.print(e); + } + } + + @Override + public void onFacingChange() { + resetRedstone(); + } + + private void resetRedstone() { + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.DOWN, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.UP, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.NORTH, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.SOUTH, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.WEST, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.EAST, (byte) 0); + } + + public void changeGateData(int aIndex, int aValue) { + mGateData[aIndex] += aValue; + validateGateData(); + } + + public void stackGateData(int aIndex, ItemStack aStack) { + mGateData[aIndex] = GTUtility.stackToInt(aStack); + validateGateData(); + } + + private void switchGate() { + resetRedstone(); + Arrays.fill(mGateData, 0); + CircuitryBehavior tBehaviour = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) try { + tBehaviour.initParameters(mGateData, this); + } catch (Throwable e) { + GTLog.err.print(e); + } + validateGateData(); + } + + private void validateGateData() { + CircuitryBehavior tBehaviour = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) try { + tBehaviour.validateParameters(mGateData, this); + } catch (Throwable e) { + GTLog.err.print(e); + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + validateGateData(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + getBaseMetaTileEntity().setGenericRedstoneOutput(true); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null; + if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { + if (getBaseMetaTileEntity().isActive()) { + CircuitryBehavior tBehaviour = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tBehaviour != null) { + try { + tBehaviour.onTick(mGateData, this); + if (tBehaviour.displayItemStack(mGateData, this, 0)) + mInventory[1] = getCoverByID(mGateData[0]); + if (tBehaviour.displayItemStack(mGateData, this, 1)) + mInventory[2] = getCoverByID(mGateData[1]); + if (tBehaviour.displayItemStack(mGateData, this, 2)) + mInventory[3] = getCoverByID(mGateData[2]); + if (tBehaviour.displayItemStack(mGateData, this, 3)) + mInventory[4] = getCoverByID(mGateData[3]); + } catch (Throwable e) { + GTLog.err.print(e); + } + } + } + getBaseMetaTileEntity().setErrorDisplayID(0); + } else { + getBaseMetaTileEntity().setErrorDisplayID(1); + } + } + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Only Calc server-side + if (!this.getBaseMetaTileEntity() + .isServerSide()) { + return; + } + // Emit Redstone + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + byte aRedstone = getBaseMetaTileEntity().getOutputRedstoneSignal(side); + this.getBaseMetaTileEntity() + .setInternalOutputRedstoneSignal(side, aRedstone); + } + } + + @Override + public final boolean hasRedstoneSignal() { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(side) > 0) { + return true; + } + } + return false; + } + + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } + + /** The Item List for Covers */ + public static final Map sCoversItems = new HashMap<>(); + + private static void initCovers() { + for (GTItemStack aKey : GregTechAPI.sCovers.keySet()) { + ItemStack aStack = aKey.toStack() + .copy(); + if (aStack != null) { + sCoversItems.put(GTUtility.stackToInt(aStack), aStack); + } + } + } + + public static ItemStack getCoverByID(int aStack) { + if (sCoversItems.isEmpty()) { + initCovers(); + } + return sCoversItems.get(Integer.valueOf(aStack)); + } + + @Override + public ForgeDirection getOutputFacing() { + return getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean setRedstone(byte aStrength, ForgeDirection side) { + if (getOutputRedstone(side) != aStrength) { + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(1, false)) { + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(side, aStrength); + getBaseMetaTileEntity().setErrorDisplayID(0); + return true; + } else { + getBaseMetaTileEntity().setErrorDisplayID(1); + return false; + } + } + return false; + } + + /* + * @Override public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { if (aSide == + * getOutputFacing()) { if (side == ForgeDirection.DOWN) return aRedstone ? 56 : 54; if (side == ForgeDirection.UP) + * return aRedstone ? 53 : 52; return aRedstone ? 94 : 93; } if (side == ForgeDirection.DOWN) return aRedstone ? 60 + * : 59; if (side == ForgeDirection.UP) return aRedstone ? 58 : 57; return aRedstone ? 62 : 61; } + */ + + @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; + } + + public byte getOutputRedstone(ForgeDirection side) { + return getBaseMetaTileEntity().getOutputRedstoneSignal(side); + } + + @Override + public byte getInputRedstone(ForgeDirection side) { + return getBaseMetaTileEntity().getInternalInputRedstoneSignal(side); + } + + @Override + public Block getBlockAtSide(ForgeDirection side) { + return getBaseMetaTileEntity().getBlockAtSide(side); + } + + @Override + public byte getMetaIDAtSide(ForgeDirection side) { + return getBaseMetaTileEntity().getMetaIDAtSide(side); + } + + @Override + public TileEntity getTileEntityAtSide(ForgeDirection side) { + return getBaseMetaTileEntity().getTileEntityAtSide(side); + } + + @Override + public int getRandom(int aRange) { + return getBaseMetaTileEntity().getRandomNumber(aRange); + } + + @Override + public CoverBehavior getCover(ForgeDirection side) { + return (CoverBehavior) getBaseMetaTileEntity().getCoverBehaviorAtSideNew(side); + } + + @Override + public int getCoverID(ForgeDirection side) { + return getBaseMetaTileEntity().getCoverIDAtSide(side); + } + + @Override + public int getCoverVariable(ForgeDirection side) { + return ((ISerializableObject.LegacyCoverData) getBaseMetaTileEntity().getComplexCoverDataAtSide(side)).get(); + } + + @Override + public ICoverable getOwnTileEntity() { + return getBaseMetaTileEntity(); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getSidesActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + private GTRenderedTexture getBase() { + return new GTRenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off), + new GTRenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On), + new GTRenderedTexture(TexturesGtBlock.Casing_InventoryManagaer_Red_Redstone) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { getBase(), new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On) }; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTPPUITextures.PICTURE_REDSTONE_CIRCUIT_SCREEN) + .setPos(43, 5) + .setSize(108, 72)); + for (int i = 0; i < 4; i++) { + final int index = i; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + ItemStack tStack = widget.getContext() + .getPlayer().inventory.getItemStack(); + if (tStack == null) { + changeGateData( + index, + clickData.mouseButton == 0 ? clickData.shift ? +128 : +1 : clickData.shift ? -128 : -1); + } else { + tStack = GTUtility.copy(tStack); + if (clickData.mouseButton != 0) tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + stackGateData(index, tStack); + } + }) + .setBackground(GTUITextures.BUTTON_STANDARD, GTPPUITextures.OVERLAY_BUTTON_PLUS_MINUS) + .setPos(7, 5 + i * 18) + .setSize(18, 18)) + .widget( + SlotWidget.phantom(inventoryHandler, i + 1) + .disableInteraction() + .setPos(25, 5 + i * 18)); + } + builder.widget( + new CycleButtonWidget().setToggle(() -> bOutput, val -> bOutput = val) + .setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE) + .setStaticTexture(GTUITextures.OVERLAY_BUTTON_EMIT_ENERGY) + .addTooltip("Toggle EU Output") + .setPos(151, 5) + .setSize(18, 18)) + .widget( + new CycleButtonWidget() + .setToggle(() -> getBaseMetaTileEntity().isActive(), val -> getBaseMetaTileEntity().setActive(val)) + .setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE) + .setStaticTexture(GTPPUITextures.OVERLAY_BUTTON_ACTIVE_STATE) + .addTooltip("Toggle Active State") + .setPos(151, 23) + .setSize(18, 18)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (clickData.mouseButton == 0) switchGateForward(clickData.shift); + else switchGateBackward(clickData.shift); + }) + .setBackground(GTUITextures.BUTTON_STANDARD, GTPPUITextures.OVERLAY_BUTTON_CHANGE_MODE) + .addTooltip("Change Redstone Circuit") + .setPos(151, 41) + .setSize(18, 18)); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> mGate, val -> mGate = val)); + for (int i = 0; i < mGateData.length; i++) { + final int index = i; + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> mGateData[index], val -> mGateData[index] = val)); + } + + builder.widget(new DrawableWidget().setDrawable(() -> { + if (getBaseMetaTileEntity().getErrorDisplayID() > 0) { + if ((getBaseMetaTileEntity().getTimer() / 5) % 2 == 0) { + return GTPPUITextures.PICTURE_ELECTRICITY_ERROR; + } else { + return null; + } + } else { + return GTPPUITextures.PICTURE_ELECTRICITY_FINE; + } + }) + .setPos(140, 9) + .setSize(7, 7)) + .widget( + new FakeSyncWidget.IntegerSyncer( + () -> getBaseMetaTileEntity().getErrorDisplayID(), + val -> getBaseMetaTileEntity().setErrorDisplayID(val))); + + builder.widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getName(); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getDescription(); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 19)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 0); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 33)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 1); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 44)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 2); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 55)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) return tCircuit.getDataDescription(mGateData, 3); + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 66)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) { + String tString = tCircuit.getDataDisplay(mGateData, 0); + return tString == null ? GTUtility.parseNumberToString(mGateData[0]) : tString; + } + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(99, 33)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) { + String tString = tCircuit.getDataDisplay(mGateData, 1); + return tString == null ? GTUtility.parseNumberToString(mGateData[1]) : tString; + } + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(99, 44)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) { + String tString = tCircuit.getDataDisplay(mGateData, 2); + return tString == null ? GTUtility.parseNumberToString(mGateData[2]) : tString; + } + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(99, 55)) + .widget(TextWidget.dynamicString(() -> { + CircuitryBehavior tCircuit = GregTechAPI.sCircuitryBehaviors.get(mGate); + if (tCircuit != null) { + String tString = tCircuit.getDataDisplay(mGateData, 3); + return tString == null ? GTUtility.parseNumberToString(mGateData[3]) : tString; + } + return ""; + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(99, 66)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneLamp.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneLamp.java new file mode 100644 index 0000000000..7b963d3c7d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneLamp.java @@ -0,0 +1,73 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTERedstoneLamp extends MTERedstoneBase { + + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[2]; + + static { + sIconList[0] = new CustomIcon("TileEntities/gt4/redstone/Lamp/off"); + sIconList[1] = new CustomIcon("TileEntities/gt4/redstone/Lamp/on"); + } + + public MTERedstoneLamp(int aID) { + super(aID, "redstone.lamp", "Redstone Controlled Lamp", 0, 0, "Redstone Controlled Lamp"); + } + + public MTERedstoneLamp(final String aName, String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 0, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERedstoneLamp(this.mName, mDescriptionArray, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) {} + + @Override + public void loadNBTData(NBTTagCompound aNBT) {} + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + getBaseMetaTileEntity().setLightValue(getBaseMetaTileEntity().getStrongestRedstone()); + getBaseMetaTileEntity().setActive(getBaseMetaTileEntity().getStrongestRedstone() > 0); + } + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 1 : 0)][aColorIndex + 1]; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(sIconList[0]) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { new GTRenderedTexture(sIconList[1]) }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthDisplay.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthDisplay.java new file mode 100644 index 0000000000..c2591c6a41 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthDisplay.java @@ -0,0 +1,138 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTERedstoneStrengthDisplay extends MTERedstoneBase { + + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[144]; + + static { + for (int i = 0; i < 144; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Display/" + i); + } + } + + public MTERedstoneStrengthDisplay(int aID, String aUnlocal, String aLocal, String aDescription) { + super(aID, aUnlocal, aLocal, 5, 0, aDescription); + } + + public MTERedstoneStrengthDisplay(final String aName, String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERedstoneStrengthDisplay(this.mName, mDescriptionArray, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mRedstoneStrength", mRedstoneStrength); + aNBT.setByte("mType", mType); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mRedstoneStrength = aNBT.getByte("mRedstoneStrength"); + mType = aNBT.getByte("mType"); + } + + @Override + public void onValueUpdate(byte aValue) { + mRedstoneStrength = (byte) (aValue & 15); + mType = (byte) (aValue >>> 4); + } + + @Override + public byte getUpdateData() { + return (byte) ((mRedstoneStrength & 15) | (mType << 4)); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + mRedstoneStrength = getBaseMetaTileEntity().getStrongestRedstone(); + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 6); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GTRenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1] }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On) }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthScale.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthScale.java new file mode 100644 index 0000000000..e59500dcc0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/MTERedstoneStrengthScale.java @@ -0,0 +1,53 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GTRenderedTexture; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class MTERedstoneStrengthScale extends MTERedstoneStrengthDisplay { + + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[32]; + + static { + for (int i = 0; i < 32; i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Scale/" + i); + } + } + + public MTERedstoneStrengthScale(int aID) { + super(aID, "redstone.display.scale", "Redstone Scale", "Redstone Strength on a Scale"); + } + + public MTERedstoneStrengthScale(final String aName, String[] aDescription, final ITexture[][][] aTextures) { + super(aName, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTERedstoneStrengthScale(this.mName, mDescriptionArray, this.mTextures); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 2); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + new GTRenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) }; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java deleted file mode 100644 index 2b1591ab80..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java +++ /dev/null @@ -1,245 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import com.gtnewhorizons.modularui.api.NumberFormatMUI; -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.SlotWidget; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; -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_TieredMachineBlock; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; - -public class GT_MetaTileEntity_TieredChest extends GT_MetaTileEntity_TieredMachineBlock implements IAddUIWidgets { - - public int mItemCount = 0; - public ItemStack mItemStack = null; - private static final double mStorageFactor = (270000.0D / 16); - - public GT_MetaTileEntity_TieredChest(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - 3, - "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", - new ITexture[0]); - } - - public GT_MetaTileEntity_TieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return ArrayUtils.add(this.mDescriptionArray, CORE.GT_Tooltip.get()); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - 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 MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredChest(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (this.getBaseMetaTileEntity() - .isServerSide() - && this.getBaseMetaTileEntity() - .isAllowedToWork()) { - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - this.mItemCount -= this.mInventory[1].stackSize; - } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) - && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { - int tmp = Math - .min(this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); - this.mInventory[1].stackSize += tmp; - this.mItemCount -= tmp; - } - - if (this.mItemStack != null) { - this.mInventory[2] = this.mItemStack.copy(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } - } - - private int getItemCount() { - return this.mItemCount; - } - - @Override - public void setItemCount(int aCount) { - this.mItemCount = aCount; - } - - @Override - public int getProgresstime() { - return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) - + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); - } - - @Override - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - @Override - public int getMaxItemCount() { - return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return aIndex == 1; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); - } - - @Override - public String[] getInfoData() { - return this.mItemStack == null - ? new String[] { "Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), - Integer.toString(this.getMaxItemCount()) } - : new String[] { "Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), - Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount()) }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if (this.mItemStack != null) { - aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mItemCount")) { - this.mItemCount = aNBT.getInteger("mItemCount"); - } - - if (aNBT.hasKey("mItemStack")) { - this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); - } - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, - int aColorIndex, boolean aActive, boolean aRedstone) { - return aBaseMetaTileEntity.getFrontFacing() == ForgeDirection.DOWN && side == ForgeDirection.WEST - ? new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) } - : (side == aBaseMetaTileEntity.getFrontFacing() - ? new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) } - : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) - .setPos(7, 16) - .setSize(71, 45)) - .widget( - new SlotWidget(inventoryHandler, 0) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN) - .setPos(79, 16)) - .widget( - new SlotWidget(inventoryHandler, 1).setAccess(true, false) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_OUT) - .setPos(79, 52)) - .widget( - SlotWidget.phantom(inventoryHandler, 2) - .disableInteraction() - .setBackground(GT_UITextures.TRANSPARENT) - .setPos(59, 42)) - .widget( - new TextWidget("Item Amount").setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(10, 20)) - .widget( - new TextWidget().setStringSupplier(() -> numberFormat.format(mItemCount)) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setPos(10, 30)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java deleted file mode 100644 index e277eb4076..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java +++ /dev/null @@ -1,189 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -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 net.minecraftforge.fluids.FluidStack; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures; -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_BasicTank; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; - -public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { - - public GT_MetaTileEntity_TieredTank(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - 3, - "Stores " + GT_Utility.formatNumbers(((int) (Math.pow(2, aTier) * 32000))) + "L of fluid"); - } - - public GT_MetaTileEntity_TieredTank(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - List description = new ArrayList<>(Arrays.asList(this.mDescriptionArray)); - description.add("A portable tank."); - if (this.mFluid != null) { - description.add("Fluid: " + mFluid.getLocalizedName() + " " + mFluid.amount + "L"); - } - description.add(CORE.GT_Tooltip.get()); - return description.toArray(new String[0]); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return side == ForgeDirection.UP - ? new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_FLUIDTANK) } - : new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_FLUIDTANK) }; - } - - @Override - public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { - if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("mFluid")) { - final FluidStack tContents = FluidStack - .loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("mFluid")); - if (tContents != null && tContents.amount > 0) { - tooltip.add( - GT_LanguageManager.addStringLocalization( - "TileEntity_TANK_INFO", - "Contains Fluid: ", - !GregTech_API.sPostloadFinished) + EnumChatFormatting.YELLOW - + tContents.getLocalizedName() - + EnumChatFormatting.GRAY); - tooltip.add( - GT_LanguageManager.addStringLocalization( - "TileEntity_TANK_AMOUNT", - "Fluid Amount: ", - !GregTech_API.sPostloadFinished) + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(tContents.amount) - + " L" - + EnumChatFormatting.GRAY); - } - } - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public final byte getUpdateData() { - return 0x00; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public String[] getInfoData() { - - if (this.mFluid == null) { - return new String[] { GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", "No Fluid", - 0 + "L", this.getCapacity() + "L" }; - } - return new String[] { GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", - this.mFluid.getLocalizedName(), this.mFluid.amount + "L", this.getCapacity() + "L" }; - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public int getCapacity() { - return (int) (Math.pow(2, this.mTier) * 32000); - } - - @Override - public int getTankPressure() { - return 100; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - if (mFluid != null) { - Logger.WARNING("Setting item fluid nbt"); - aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - if (aNBT.hasKey("mFluid")) { - Logger.WARNING("Set mFluid to NBT."); - } - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java deleted file mode 100644 index 17b2d77756..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ /dev/null @@ -1,439 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import static gregtech.api.enums.GT_Values.V; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { - - protected byte aCurrentOutputAmperage = 4; - - public GregtechMetaEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Defaults 4A In/Out", "Change output Amperage with a screwdriver", - "Now Portable!", CORE.GT_Tooltip.get() }; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCover) { - if (side != this.getBaseMetaTileEntity() - .getFrontFacing()) { - return true; - } - return super.allowCoverOnSide(side, aCover); - } - - /* - * MACHINE_STEEL_SIDE - */ - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaEnergyBuffer( - this.mName, - this.mTier, - this.mDescription, - this.mTextures, - this.mInventory.length); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity() - .getFrontFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return V[this.mTier] * 2; - } - - @Override - public long maxEUStore() { - return V[this.mTier] * 250000; - } - - @Override - public long maxEUInput() { - return V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return V[this.mTier]; - } - - @Override - public long maxAmperesIn() { - return aCurrentOutputAmperage; - } - - @Override - public long maxAmperesOut() { - return aCurrentOutputAmperage; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return 0; - } - - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyStored(); - } - - @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity() - .getUniversalEnergyCapacity(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); - long aEU = this.getBaseMetaTileEntity() - .getStoredEU(); - if (aEU > 0) { - aNBT.setLong("aStoredEU", aEU); - if (aNBT.hasKey("aStoredEU")) { - Logger.WARNING("Set aStoredEU to NBT."); - } - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - aCurrentOutputAmperage = aNBT.getByte("aCurrentOutputAmperage"); - if (aNBT.hasKey("aStoredEU")) { - this.setEUVar(aNBT.getLong("aStoredEU")); - } - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - Logger.WARNING("Right Click on MTE by Player"); - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - - Logger.WARNING("MTE is Client-side"); - this.showEnergy(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - protected void showEnergy(final World worldIn, final EntityPlayer playerIn) { - final long tempStorage = this.getBaseMetaTileEntity() - .getStoredEU(); - final double c = ((double) tempStorage / this.maxEUStore()) * 100; - final double roundOff = Math.round(c * 100.00) / 100.00; - PlayerUtils.messagePlayer( - playerIn, - "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at " + V[this.mTier] + "v (" + roundOff + "%)"); - PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut()) + "A"); - } - // Utils.LOG_WARNING("Begin Show Energy"); - /* - * //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); - * Utils.LOG_INFO("getProgressTime: "+getProgresstime()); Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); - * Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); Utils.LOG_INFO("maxEUStore: "+maxEUStore()); - */ - /* - * final long d = (tempStorage * 100L) / maxEUStore(); - * Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); final double - * roundOff2 = Math.round(d * 100.00) / 100.00; Utils.messagePlayer(playerIn, "Energy: " + tempStorage + - * " EU at "+V[mTier]+"v ("+roundOff2+"%)"); Utils.LOG_WARNING("Making new instance of Guihandler"); GuiHandler - * block = new GuiHandler(); Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); - * block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); - */ - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - String cur = GT_Utility.formatNumbers( - this.getBaseMetaTileEntity() - .getStoredEU()); - String max = GT_Utility.formatNumbers( - this.getBaseMetaTileEntity() - .getEUCapacity()); - - // Right-align current storage with maximum storage - String fmt = String.format("%%%ds", max.length()); - cur = String.format(fmt, cur); - - return new String[] { cur + " EU stored", max + " EU capacity" }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} - - @Override - public String getInventoryName() { - return super.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return false; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); - long aEU = this.getBaseMetaTileEntity() - .getStoredEU(); - if (aEU > 0) { - aNBT.setLong("aStoredEU", aEU); - if (aNBT.hasKey("aStoredEU")) { - Logger.WARNING("Set aStoredEU to NBT."); - } - } - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - byte aTest = (byte) (aCurrentOutputAmperage + 1); - if (aTest > 16 || aTest <= 0) { - aTest = 1; - } - aCurrentOutputAmperage = aTest; - PlayerUtils.messagePlayer(aPlayer, "Now handling " + aCurrentOutputAmperage + " Amps."); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTEEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTEEnergyBuffer.java new file mode 100644 index 0000000000..ed4ff6b4ca --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTEEnergyBuffer.java @@ -0,0 +1,434 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import static gregtech.api.enums.GTValues.V; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GTItemStack; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class MTEEnergyBuffer extends GTPPMetaTileEntity { + + protected byte aCurrentOutputAmperage = 4; + + public MTEEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public MTEEnergyBuffer(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Defaults 4A In/Out", "Change output Amperage with a screwdriver", + "Now Portable!", GTPPCore.GT_Tooltip.get() }; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GTItemStack aCover) { + if (side != this.getBaseMetaTileEntity() + .getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(side, aCover); + } + + /* + * MACHINE_STEEL_SIDE + */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (side == facing ? 0 + : side == facing.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTEEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(final ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(final ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[this.mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[this.mTier] * 250000; + } + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return aCurrentOutputAmperage; + } + + @Override + public long maxAmperesOut() { + return aCurrentOutputAmperage; + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } + + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity() + .getUniversalEnergyCapacity(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + long aEU = this.getBaseMetaTileEntity() + .getStoredEU(); + if (aEU > 0) { + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + aCurrentOutputAmperage = aNBT.getByte("aCurrentOutputAmperage"); + if (aNBT.hasKey("aStoredEU")) { + this.setEUVar(aNBT.getLong("aStoredEU")); + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + Logger.WARNING("Right Click on MTE by Player"); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + + Logger.WARNING("MTE is Client-side"); + this.showEnergy(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + protected void showEnergy(final World worldIn, final EntityPlayer playerIn) { + final long tempStorage = this.getBaseMetaTileEntity() + .getStoredEU(); + final double c = ((double) tempStorage / this.maxEUStore()) * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer( + playerIn, + "Energy: " + GTUtility.formatNumbers(tempStorage) + " EU at " + V[this.mTier] + "v (" + roundOff + "%)"); + PlayerUtils.messagePlayer(playerIn, "Amperage: " + GTUtility.formatNumbers(maxAmperesOut()) + "A"); + } + // Utils.LOG_WARNING("Begin Show Energy"); + /* + * //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); + * Utils.LOG_INFO("getProgressTime: "+getProgresstime()); Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); + * Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); Utils.LOG_INFO("maxEUStore: "+maxEUStore()); + */ + /* + * final long d = (tempStorage * 100L) / maxEUStore(); + * Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); final double + * roundOff2 = Math.round(d * 100.00) / 100.00; Utils.messagePlayer(playerIn, "Energy: " + tempStorage + + * " EU at "+V[mTier]+"v ("+roundOff2+"%)"); Utils.LOG_WARNING("Making new instance of Guihandler"); GuiHandler + * block = new GuiHandler(); Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); + * block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); + */ + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, + final ForgeDirection side, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String cur = GTUtility.formatNumbers( + this.getBaseMetaTileEntity() + .getStoredEU()); + String max = GTUtility.formatNumbers( + this.getBaseMetaTileEntity() + .getEUCapacity()); + + // Right-align current storage with maximum storage + String fmt = String.format("%%%ds", max.length()); + cur = String.format(fmt, cur); + + return new String[] { cur + " EU stored", max + " EU capacity" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} + + @Override + public String getInventoryName() { + return super.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + long aEU = this.getBaseMetaTileEntity() + .getStoredEU(); + if (aEU > 0) { + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + byte aTest = (byte) (aCurrentOutputAmperage + 1); + if (aTest > 16 || aTest <= 0) { + aTest = 1; + } + aCurrentOutputAmperage = aTest; + PlayerUtils.messagePlayer(aPlayer, "Now handling " + aCurrentOutputAmperage + " Amps."); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredChest.java new file mode 100644 index 0000000000..423a71c3e1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredChest.java @@ -0,0 +1,245 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +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.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +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.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import gtPlusPlus.core.lib.GTPPCore; + +public class MTETieredChest extends MTETieredMachineBlock implements IAddUIWidgets { + + public int mItemCount = 0; + public ItemStack mItemStack = null; + private static final double mStorageFactor = (270000.0D / 16); + + public MTETieredChest(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 3, + "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", + new ITexture[0]); + } + + public MTETieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return ArrayUtils.add(this.mDescriptionArray, GTPPCore.GT_Tooltip.get()); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + 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 MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTETieredChest(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity() + .isServerSide() + && this.getBaseMetaTileEntity() + .isAllowedToWork()) { + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + + if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() + && GTUtility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 && GTUtility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = Math + .min(this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + @Override + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + @Override + public int getProgresstime() { + return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + @Override + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + @Override + public int getMaxItemCount() { + return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return aIndex == 0 && (this.mInventory[0] == null || GTUtility.areStacksEqual(this.mInventory[0], aStack)); + } + + @Override + public String[] getInfoData() { + return this.mItemStack == null + ? new String[] { "Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), + Integer.toString(this.getMaxItemCount()) } + : new String[] { "Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), + Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount()) }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + return aBaseMetaTileEntity.getFrontFacing() == ForgeDirection.DOWN && side == ForgeDirection.WEST + ? new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GTRenderedTexture(BlockIcons.OVERLAY_QCHEST) } + : (side == aBaseMetaTileEntity.getFrontFacing() + ? new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GTRenderedTexture(BlockIcons.OVERLAY_QCHEST) } + : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 16) + .setSize(71, 45)) + .widget( + new SlotWidget(inventoryHandler, 0) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_IN) + .setPos(79, 16)) + .widget( + new SlotWidget(inventoryHandler, 1).setAccess(true, false) + .setBackground(getGUITextureSet().getItemSlot(), GTUITextures.OVERLAY_SLOT_OUT) + .setPos(79, 52)) + .widget( + SlotWidget.phantom(inventoryHandler, 2) + .disableInteraction() + .setBackground(GTUITextures.TRANSPARENT) + .setPos(59, 42)) + .widget( + new TextWidget("Item Amount").setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 20)) + .widget( + new TextWidget().setStringSupplier(() -> numberFormat.format(mItemCount)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 30)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredTank.java new file mode 100644 index 0000000000..fb766b9dd5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredTank.java @@ -0,0 +1,188 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +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 net.minecraftforge.fluids.FluidStack; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicTank; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.GTPPCore; + +public class MTETieredTank extends MTEBasicTank { + + public MTETieredTank(final int aID, final String aName, final String aNameRegional, final int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 3, + "Stores " + GTUtility.formatNumbers(((int) (Math.pow(2, aTier) * 32000))) + "L of fluid"); + } + + public MTETieredTank(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + List description = new ArrayList<>(Arrays.asList(this.mDescriptionArray)); + description.add("A portable tank."); + if (this.mFluid != null) { + description.add("Fluid: " + mFluid.getLocalizedName() + " " + mFluid.amount + "L"); + } + description.add(GTPPCore.GT_Tooltip.get()); + return description.toArray(new String[0]); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, + final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { + return side == ForgeDirection.UP + ? new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_TOP_FLUIDTANK) } + : new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_FLUIDTANK) }; + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List tooltip) { + if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("mFluid")) { + final FluidStack tContents = FluidStack + .loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("mFluid")); + if (tContents != null && tContents.amount > 0) { + tooltip.add( + GTLanguageManager.addStringLocalization( + "TileEntity_TANK_INFO", + "Contains Fluid: ", + !GregTechAPI.sPostloadFinished) + EnumChatFormatting.YELLOW + + tContents.getLocalizedName() + + EnumChatFormatting.GRAY); + tooltip.add( + GTLanguageManager.addStringLocalization( + "TileEntity_TANK_AMOUNT", + "Fluid Amount: ", + !GregTechAPI.sPostloadFinished) + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(tContents.amount) + + " L" + + EnumChatFormatting.GRAY); + } + } + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(final ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public String[] getInfoData() { + + if (this.mFluid == null) { + return new String[] { GTValues.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", "No Fluid", + 0 + "L", this.getCapacity() + "L" }; + } + return new String[] { GTValues.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", + this.mFluid.getLocalizedName(), this.mFluid.amount + "L", this.getCapacity() + "L" }; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new MTETieredTank(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public int getCapacity() { + return (int) (Math.pow(2, this.mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (mFluid != null) { + Logger.WARNING("Setting item fluid nbt"); + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + if (aNBT.hasKey("mFluid")) { + Logger.WARNING("Set mFluid to NBT."); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java deleted file mode 100644 index 2dca8d5c30..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java +++ /dev/null @@ -1,92 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; - -public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_TieredChest { - - public GT_MetaTileEntity_InfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_InfiniteItemHolder(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.getWorld().isRemote) { - return false; - } - - if (!KeyboardUtils.isShiftKeyDown()) { - if (this.mItemStack == null) { - if (aPlayer.getHeldItem() != null) { - this.mItemStack = aPlayer.getHeldItem() - .copy(); - this.mItemCount = Short.MAX_VALUE; - aPlayer.setCurrentItemOrArmor(0, null); - PlayerUtils.messagePlayer( - aPlayer, - "Now holding " + this.mItemStack.getDisplayName() + " x" + Short.MAX_VALUE + "."); - return true; - } - } else { - if (aPlayer.getHeldItem() == null) { - aPlayer.entityDropItem(mItemStack, 1); - this.mItemStack = null; - this.mItemCount = 0; - PlayerUtils.messagePlayer(aPlayer, "Emptying."); - return true; - } - } - } - - PlayerUtils.messagePlayer( - aPlayer, - "Currently holding: " + (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing") - + " x" - + this.mItemCount); - return true; - // return super.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (mItemStack != null) { - setItemCount(0); - } - super.onPostTick(aBaseMetaTileEntity, aTimer); - } - - @Override - public void setItemCount(int aCount) { - super.setItemCount(Short.MAX_VALUE); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return false; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/MTEInfiniteItemHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/MTEInfiniteItemHolder.java new file mode 100644 index 0000000000..677fe1a1c9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/MTEInfiniteItemHolder.java @@ -0,0 +1,91 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.MTETieredChest; + +public class MTEInfiniteItemHolder extends MTETieredChest { + + public MTEInfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public MTEInfiniteItemHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + return false; + } + + if (!KeyboardUtils.isShiftKeyDown()) { + if (this.mItemStack == null) { + if (aPlayer.getHeldItem() != null) { + this.mItemStack = aPlayer.getHeldItem() + .copy(); + this.mItemCount = Short.MAX_VALUE; + aPlayer.setCurrentItemOrArmor(0, null); + PlayerUtils.messagePlayer( + aPlayer, + "Now holding " + this.mItemStack.getDisplayName() + " x" + Short.MAX_VALUE + "."); + return true; + } + } else { + if (aPlayer.getHeldItem() == null) { + aPlayer.entityDropItem(mItemStack, 1); + this.mItemStack = null; + this.mItemCount = 0; + PlayerUtils.messagePlayer(aPlayer, "Emptying."); + return true; + } + } + } + + PlayerUtils.messagePlayer( + aPlayer, + "Currently holding: " + (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing") + + " x" + + this.mItemCount); + return true; + // return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (mItemStack != null) { + setItemCount(0); + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + @Override + public void setItemCount(int aCount) { + super.setItemCount(Short.MAX_VALUE); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEInfiniteItemHolder(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java deleted file mode 100644 index 6af3a61487..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java +++ /dev/null @@ -1,175 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tools; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityIronGolem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.AchievementList; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.event.world.BlockEvent; - -import gregtech.GT_Mod; -import gregtech.api.enums.Materials; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.Textures.ItemIcons; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.common.items.behaviors.Behaviour_None; -import gregtech.common.tools.GT_Tool; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; - -public class TOOL_Gregtech_AngleGrinder extends GT_Tool { - - public static final List mEffectiveList = Arrays - .asList(new String[] { EntityIronGolem.class.getName(), "EntityTowerGuardian" }); - - @Override - public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, - final EntityPlayer aPlayer) { - String tName = aEntity.getClass() - .getName(); - tName = tName.substring(tName.lastIndexOf(".") + 1); - return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; - } - - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 8.0F; - } - - @Override - public float getSpeedMultiplier() { - return 2F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.8F; - } - - @Override - public String getCraftingSound() { - return SoundResource.RANDOM_ANVIL_USE.toString(); - } - - @Override - public String getEntityHitSound() { - return SoundResource.RANDOM_ANVIL_BREAK.toString(); - } - - @Override - public String getMiningSound() { - return null; - } - - @Override - public boolean canBlock() { - return false; - } - - @Override - public boolean isWrench() { - return false; - } - - @Override - public boolean isCrowbar() { - return false; - } - - @Override - public boolean isWeapon() { - return true; - } - - @Override - public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { - final String tTool = aBlock.getHarvestTool(aMetaData); - return (tTool != null) && (tTool.equals("sword") || tTool.equals("file")); - } - - @Override - public int convertBlockDrops(final List aDrops, final ItemStack aStack, final EntityPlayer aPlayer, - final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, - final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - return 0; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - @Override - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead ? TexturesGtTools.ANGLE_GRINDER : ItemIcons.POWER_UNIT_HV); - } - - @Override - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; - } - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) {} - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText( - EnumChatFormatting.RED + aEntity.getCommandSenderName() - + EnumChatFormatting.WHITE - + " has been Ground out of existence by " - + EnumChatFormatting.GREEN - + aPlayer.getCommandSenderName() - + EnumChatFormatting.WHITE); - } - - @Override - public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { - aItem.addItemBehavior(aID, new Behaviour_None()); - } - - @Override - public boolean isGrafter() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java deleted file mode 100644 index 25ad03548a..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java +++ /dev/null @@ -1,96 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tools; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.AchievementList; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; - -import gregtech.GT_Mod; -import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures.ItemIcons; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.common.tools.GT_Tool_WireCutter; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; - -public class TOOL_Gregtech_ElectricSnips extends GT_Tool_WireCutter { - - @Override - public int getToolDamagePerBlockBreak() { - return 50; - } - - @Override - public int getToolDamagePerDropConversion() { - return 100; - } - - @Override - public int getToolDamagePerContainerCraft() { - return 400; - } - - @Override - public int getToolDamagePerEntityAttack() { - return 100; - } - - @Override - public int getBaseQuality() { - return 0; - } - - @Override - public float getBaseDamage() { - return 4.0F; - } - - @Override - public float getSpeedMultiplier() { - return 1F; - } - - @Override - public float getMaxDurabilityMultiplier() { - return 1.4F; - } - - @Override - public ItemStack getBrokenItem(final ItemStack aStack) { - return null; - } - - @Override - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { - return (IIconContainer) (aIsToolHead ? TexturesGtTools.ELECTRIC_SNIPS : ItemIcons.POWER_UNIT_MV); - } - - @Override - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { - return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; - } - - @Override - public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { - super.onToolCrafted(aStack, aPlayer); - aPlayer.triggerAchievement(AchievementList.buildSword); - try { - GT_Mod.achievements.issueAchievement(aPlayer, "tools"); - GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); - } catch (final Exception e) {} - } - - @Override - public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { - return new ChatComponentText( - EnumChatFormatting.RED + aEntity.getCommandSenderName() - + EnumChatFormatting.WHITE - + " has been Snipped out of existence by " - + EnumChatFormatting.GREEN - + aPlayer.getCommandSenderName() - + EnumChatFormatting.WHITE); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolAngleGrinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolAngleGrinder.java new file mode 100644 index 0000000000..196bc2a5bb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolAngleGrinder.java @@ -0,0 +1,175 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.event.world.BlockEvent; + +import gregtech.GTMod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.MetaGeneratedTool; +import gregtech.common.items.behaviors.BehaviourNone; +import gregtech.common.tools.GTTool; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; + +public class ToolAngleGrinder extends GTTool { + + public static final List mEffectiveList = Arrays + .asList(new String[] { EntityIronGolem.class.getName(), "EntityTowerGuardian" }); + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, + final EntityPlayer aPlayer) { + String tName = aEntity.getClass() + .getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return SoundResource.RANDOM_ANVIL_USE.toString(); + } + + @Override + public String getEntityHitSound() { + return SoundResource.RANDOM_ANVIL_BREAK.toString(); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + @Override + public boolean isWrench() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return (tTool != null) && (tTool.equals("sword") || tTool.equals("file")); + } + + @Override + public int convertBlockDrops(final List aDrops, final ItemStack aStack, final EntityPlayer aPlayer, + final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, + final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + return 0; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ANGLE_GRINDER : ItemIcons.POWER_UNIT_HV); + } + + @Override + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead ? MetaGeneratedTool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GTMod.achievements.issueAchievement(aPlayer, "tools"); + GTMod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) {} + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText( + EnumChatFormatting.RED + aEntity.getCommandSenderName() + + EnumChatFormatting.WHITE + + " has been Ground out of existence by " + + EnumChatFormatting.GREEN + + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final MetaGeneratedTool aItem, final int aID) { + aItem.addItemBehavior(aID, new BehaviourNone()); + } + + @Override + public boolean isGrafter() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolElectricSnips.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolElectricSnips.java new file mode 100644 index 0000000000..78675f70d5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/ToolElectricSnips.java @@ -0,0 +1,96 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +import gregtech.GTMod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.MetaGeneratedTool; +import gregtech.common.tools.ToolWireCutter; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; + +public class ToolElectricSnips extends ToolWireCutter { + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 4.0F; + } + + @Override + public float getSpeedMultiplier() { + return 1F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.4F; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead ? TexturesGtTools.ELECTRIC_SNIPS : ItemIcons.POWER_UNIT_MV); + } + + @Override + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead ? MetaGeneratedTool.getPrimaryMaterial(aStack).mRGBa : Materials.TungstenSteel.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GTMod.achievements.issueAchievement(aPlayer, "tools"); + GTMod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) {} + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText( + EnumChatFormatting.RED + aEntity.getCommandSenderName() + + EnumChatFormatting.WHITE + + " has been Snipped out of existence by " + + EnumChatFormatting.GREEN + + aPlayer.getCommandSenderName() + + EnumChatFormatting.WHITE); + } +} -- cgit